s = input()
n = len(s)

ans = n
b = 1
for i in range(1, n):
    if s[i-1] == s[i]:
        b += 1
    else:
        ans -= (b+1) // 3
        if b >= 2 and b % 3 > 0:
            b = 0
        else:
            b = 1
    # print(i,ans,b)

ans -= (b+1) // 3

print(ans)
