input_data = []
data = input()



i=0
k=0

#最後二つが同じなら削除
inv_data=data[::-1]
memory=inv_data[0]
count=1
for ch in inv_data[1:]:
    if ch==memory:
        count+=1
    else:
        break
if count>=2:
    if count%2!=0:
        count-=1

    k+=count//2
    
    data=data[:len(data)-count] 


memory="first"
max_len=len(data)
while max_len!=i:
    if data[i] != memory:
        memory=data[i]
        i+=1             
    else:
   
        memory=data[i:i+2]
        i+=2
    k+=1
    
print(k)