s = str(input())

l = list(s)

info = [0]

for i in range(1,len(l)):
    if l[i] == l[i-1]:
        info[-1] += 1
    else:
        info.append(1)

ans = 0
for j in range(0,len(info)):
    if info[j] % 3 == 0:
        ans += 2*(info[j]//3)
    elif info[j] % 3 == 1:
        ans += 2*(info[j]//3) + 1
    else:
        if j < len(info):
            ans += 2*(info[j]//3) + 2
            info[j+1] -= 1
        else:
            ans += 2*(info[j]//3) + 1

print(ans)