S = input()
N = len(S)

dp = [[-1] * (3) for _ in range(N+200)]
dp[0][1] = 1
dp[0][2] = 1

for i in range(N - 1):
    dp[i + 1][1] = max(dp[i + 1][1], dp[i][2] + 1)
    if S[i + 1] != S[i]:
        dp[i + 1][1] = max(dp[i + 1][1], dp[i][1] + 1)
    dp[i + 1][2] = max(dp[i + 1][2], dp[i][1])

# print(dp[N - 1][1])
# print(dp[N - 1][2])

print(max(dp[N-1][1], dp[N-1][2]))