def count_a(n):
    if(n%3==1):
        return n // 3 + 1
    elif(n%3==2):
        return n // 3 + 1
    else:
        return (n // 3)*2

s = input()

cnt = 0
st = 0
twice = []
twice_count = 0
mo = []
for i in range(len(s)):
    if(s[i:i+1]!=s[i+1:i+2]):
        mo.append(s[st:i+1])
        st = i+1
for i in range(len(mo)):
    if((len(mo[i])%3)==2):
        twice_count += 1
    else:
        if(twice_count > 0):
            twice.append(twice_count)
            twice_count = 0
    cnt += count_a(len(mo[i]))
twice.append(twice_count)
for i in range(len(twice)):
    cnt += twice[i] // 2
print(cnt)