s = input()
A = [1]
n = len(s)


for i in range(1, n):
    if s[i] == s[i-1]:
        A[-1] += 1
    else:
        A.append(1)

# print(A)
ans = 0
for i in range(len(A)-1):
    if A[i] > 1 or A[i+1] > 1:
        A[i] -= 1
        A[i+1] -= 1
        ans += 1
# print(A)
for i in range(len(A)):
    ans += (A[i]//3)* 2 + min(1, A[i]%3)

print(ans)