S=input()

seq=[]
tmp=S[0]
cnt=0
for i in range(len(S)):
    if S[i]==tmp:
        cnt+=1
    else:
        seq.append(cnt)
        tmp=S[i]
        cnt=1
seq.append(cnt)
#print(seq)

devidelist=[]
for i in range(len(seq)):
    if seq[i]==1:
        devidelist.append(1)
    elif seq[i]==2:
        if i<len(seq)-1:
            devidelist.append(1)
            devidelist.append(2)
            seq[i+1]-=1
        else:
            devidelist.append(2)
    elif seq[i]>=3:
        for j in range(seq[i]//3):
            devidelist.append(1)
            devidelist.append(2)
        if seq[i]%3!=0:
            devidelist.append(1)
#print(devidelist)
print(len(devidelist))