def main(): from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum from heapq import heapify, heappop, heappush from bisect import bisect_left, bisect_right from copy import deepcopy import copy import random from collections import deque,Counter,defaultdict from itertools import permutations,combinations from decimal import Decimal,ROUND_HALF_UP #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP) from functools import lru_cache, reduce #@lru_cache(maxsize=None) from operator import add,sub,mul,xor,and_,or_,itemgetter INF = 10**18 mod1 = 10**9+7 mod2 = 998244353 #DecimalならPython #再帰ならPython!!!!!!!!!!!!!!!!!!!!!!!!!! ''' これ、移動させても被りはしないのか 一辺を2とする 上向き三角のとき 右に移動するとき、(1,√3)移動する 下に移動するとき、(0,-1)移動する 左に移動するとき、(-1,√3移動する) 下向き三角のとき 逆 ''' S = list(input()) N = len(S) st = set() u = 'a' r = 'c' l = 'b' x,y = 0,0 st.add((x,y)) rev = 1 for i in range(N): if rev == 1: if S[i] == u: dx,dy = 0,-1 elif S[i] == l: dx,dy = -1,1 if l == 'b': u = 'c' r = 'b' l = 'a' elif l == 'a': u = 'b' r = 'a' l = 'c' else: u = 'a' l = 'b' r = 'c' else: dx,dy = 1,1 if u == 'a': u = 'b' l = 'c' r = 'a' elif u == 'b': u = 'c' l = 'a' r = 'b' else: u = 'a' r = 'c' l = 'b' else: if S[i] == r: dx,dy = 1,-1 if u == 'a': u = 'b' r = 'a' l = 'c' elif u == 'b': u = 'c' r = 'b' l = 'a' else: u = 'a' r = 'c' l = 'b' elif S[i] == u: dx,dy = 0,1 else: dx,dy = -1,-1 if u == 'a': u = 'c' l = 'a' r = 'b' elif u == 'b': u = 'a' l = 'b' r = 'c' else: u = 'b' l = 'c' r = 'a' x += dx y += dy st.add((x,y)) rev *= -1 print(len(st)) if __name__ == '__main__': main()