import sys def S(): return sys.stdin.readline().rstrip() S = S() ANS = set() state = 1 a,b,c = 0,0,0 ANS.add((a,b,c)) for s in S: if state == 1: if s == 'a': state = 2 a += 1 elif s == 'b': state = 3 b += 1 else: state = 4 c += 1 elif state == 2: if s == 'a': state = 1 a += -1 elif s == 'b': state = 5 c += -1 else: state = 6 b += -1 elif state == 3: if s == 'a': state = 6 c += -1 elif s == 'b': state = 1 b += -1 else: state = 5 a += -1 elif state == 4: if s == 'a': state = 5 b += -1 elif s == 'b': state = 6 a += -1 else: state = 1 c += -1 elif state == 5: if s == 'a': state = 4 b += 1 elif s == 'b': state = 2 c += 1 else: state = 3 a += 1 else: if s == 'a': state = 3 c += 1 elif s == 'b': state = 4 a += 1 else: state = 2 b += 1 ANS.add((a,b,c)) print(len(ANS))