S=input()

prev = None
cnt=0
cnt_lst=list()
for char in S:
  if char == prev :
    cnt+=1
    cnt_lst[-1] = cnt
    
  else:
    cnt_lst.append(1)
    
    cnt=1
  prev =char
ans =sum([(cnt//3)*2 for cnt in cnt_lst])
#print(cnt_lst)
cnt_lst = [cnt%3 for cnt in cnt_lst]

for index in range( len(cnt_lst)):
  
  #print(cnt_lst[index]+cnt_lst[index-1])
  if cnt_lst[index]>0:
    ans+=1
  if index>0 and cnt_lst[index]+cnt_lst[index-1]==4:
    ans+=1
    cnt_lst[index]=0
        
print(ans)
