import sys input = sys.stdin.readline S=input().strip() NOW=[0,0] PX="c" MX="a" Y="b" plus = 0 DICT={(0,0)} for s in S: if s==PX: NOW[0]+=1 PX, MX, Y = Y, PX, MX plus = 1 - plus elif s==MX: NOW[0]-=1 PX, MX, Y = MX, Y, PX plus = 1 - plus else: if plus == 0: NOW[1]-=1 else: NOW[1]+=1 PX, MX, Y = MX, PX, Y DICT.add(tuple(NOW)) print(len(DICT))