S = input()
ans = 1
n = len(S)

m = []
t = 1
for i in range(1,n):
    if S[i-1] == S[i]: t += 1
    else: 
        m.append(t)
        t = 1
m.append(t)
ans = 0
for a in m:
    ans += (a//3)*2 + (1 if a % 3 != 0 else 0)
i = 1
while i < len(m):
    if m[i-1] == m[i] == 2:
        i += 1
        ans += 1
    i += 1
print(ans)