S = input() x = 0 y = 0 cnt = 0 a = -1 b = 1 c = -1 LIST = [(0,0)] for i in range(len(S)): if S[i]=='a': y += a a = -a if S[i]=='b': x += b b = -b a = -a c = -c if S[i]=='c': x += c b = -b a = -a c = -c LIST.append((x,y)) print(len(set(LIST)))