S = [ord(s) for s in input().strip()]

def f(x):
    res = 0
    if x % 3 == 0:
        res += 1
    res += -((-x)//3) * 2 - 1
    return res

stack = []
L = []
pre = 0
for s in S:
    if s == pre:
        stack.append(s)
    else:
        L.append(len(stack))
        stack = [s]
        pre = s
if stack:
    L.append(len(stack))

L = L[1:]
Lm = [1 if l%3 == 2 else 0 for l in L]
ans = 0
pre = 0
for lm in Lm:
    if pre and lm:
        lm -= 1
        pre = lm
        ans += 1
    else:
        pre = lm

ans += sum(f(x) for x in L)
print(ans)