#!/usr/bin/env python3

s = eval(input())

n = len(s)

dp = {}

dp[(0, 1)] = 1

dp[(0, 2)] = 1

dp[(1, 2)] = dp[(0, 1)] + (s[0] != s[1])

dp[(1, 3)] = dp[(0, 1)] + 1

for i in range(2, n):

    for j in [1, 2]:

        dp[(i, i + j)] = 0

        for k in [1, 2]:

            now = s[i - k:i]

            nxt = s[i:i + j]

            dp[(i, i + j)] = max(dp[(i, i + j)], dp[(i - k, i)] + (now != nxt))

print((dp[(n - 1, n)]))

#!/usr/bin/env python3

s = eval(input())

n = len(s)

dp = [[0] * 2 for _ in range(n)]

dp[0][0] = 1

dp[0][1] = 1

dp[1][0] = dp[0][1] + (s[0] != s[1])

dp[1][1] = dp[0][1] + 1

for i in range(2, n):

    for j in range(2):

        for k in range(2):

            now = s[i - k - 1:i]

            nxt = s[i:i + j + 1]

            dp[i][j] = max(dp[i][j], dp[i - k - 1][k] + (now != nxt))

print((max(dp[n - 1])))

#!/usr/bin/env python3
s = eval(input())
n = len(s)
dp = {}
dp[(0, 1)] = 1
dp[(0, 2)] = 1
dp[(1, 2)] = dp[(0, 1)] + (s[0] != s[1])
dp[(1, 3)] = dp[(0, 1)] + 1
for i in range(2, n):
    for j in [1, 2]:
        dp[(i, i + j)] = 0
        for k in [1, 2]:
            now = s[i - k : i]
            nxt = s[i : i + j]
            dp[(i, i + j)] = max(dp[(i, i + j)], dp[(i - k, i)] + (now != nxt))
print((dp[(n - 1, n)]))

#!/usr/bin/env python3
s = eval(input())
n = len(s)
dp = [[0] * 2 for _ in range(n)]
dp[0][0] = 1
dp[0][1] = 1
dp[1][0] = dp[0][1] + (s[0] != s[1])
dp[1][1] = dp[0][1] + 1
for i in range(2, n):
    for j in range(2):
        for k in range(2):
            now = s[i - k - 1 : i]
            nxt = s[i : i + j + 1]
            dp[i][j] = max(dp[i][j], dp[i - k - 1][k] + (now != nxt))
print((max(dp[n - 1])))

-dp = {} -dp[(0, 1)] = 1 -dp[(0, 2)] = 1 -dp[(1, 2)] = dp[(0, 1)] + (s[0] != s[1]) -dp[(1, 3)] = dp[(0, 1)] + 1 +dp = [[0] * 2 for _ in range(n)] +dp[0][0] = 1 +dp[0][1] = 1 +dp[1][0] = dp[0][1] + (s[0] != s[1]) +dp[1][1] = dp[0][1] + 1 -    for j in [1, 2]: -        dp[(i, i + j)] = 0 -        for k in [1, 2]: -            now = s[i - k : i] -            nxt = s[i : i + j] -            dp[(i, i + j)] = max(dp[(i, i + j)], dp[(i - k, i)] + (now != nxt)) -print((dp[(n - 1, n)])) +    for j in range(2): +        for k in range(2): +            now = s[i - k - 1 : i] +            nxt = s[i : i + j + 1] +            dp[i][j] = max(dp[i][j], dp[i - k - 1][k] + (now != nxt)) +print((max(dp[n - 1])))