S=input()
L=[]
K=[]
tmp=1
ans=0
flag=0
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        tmp+=1
    else:
        L.append(tmp)
        tmp=1
    if i==(len(S)-2):
        L.append(tmp)
for i in range(len(L)):
    a=L[i]
    if a==2:
        flag=1
    for i in range(L[i]):
        if i%2==0:
            a-=1
        else:
            a-=2
        if a>=0:
            ans+=1
    if flag==1:
        K.append(1)
    else:
        K.append(0)
p=0
for i in range(len(K)-1):
    if p==1:
        p=0
        continue
    if K[i]==K[i+1]==1:
        ans+=1
        p=1
print(ans)
