from collections import deque

S = input()
dp = [0]*len(S)
dp[0] = 1
j = 1
s = deque([])
for i in range(1, len(S)):
    if S[i] != S[i-1]:
        dp[i] = dp[i-1] + 1
        s.append(j)
        j = 1
    else:
        j += 1
        if j % 3 == 0 or j % 3 == 1:
            dp[i] = dp[i-1] + 1
        else:
            dp[i] = dp[i-1]
ans = 0
if len(s) > 1:
    i = 1
    while i < len(s):
        if s[i] % 3 == 2 and s[i-1] % 3 == 2:
            ans += 1
            i += 2
        else:
            i += 1

print(dp[len(S)-1] + ans)