mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline S = input().rstrip('\n') up = {(0, 0)} down = set() x, y = 0, 0 flg = 0 D = [0, 1, 2] for ss in S: s = ord(ss) - 97 #print(D) if flg == 0: if D[s] == 0: x -= 1 elif D[s] == 1: y += 1 D[0], D[1], D[2] = D[1], D[2], D[0] else: D[0], D[1], D[2] = D[2], D[0], D[1] flg = 1 down.add((x, y)) else: if D[s] == 0: x += 1 elif D[s] == 1: D[0], D[1], D[2] = D[1], D[2], D[0] else: y -= 1 D[0], D[1], D[2] = D[2], D[0], D[1] flg = 0 up.add((x, y)) #print(x, y, D) print(len(up) + len(down)) #print(up) #print(down) if __name__ == '__main__': main()