import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)



S = input().rstrip()



if len(S) == 1:

    print((1))

    exit()



# n文字目を最後に長さ1,2で見る

INF = 10 ** 10

dp_1 = [-INF] * (len(S))

dp_2 = [-INF] * (len(S))



dp_1[0] = 1

dp_2[1] = 1

if S[0] != S[1]:

    dp_1[1] = 2



for i,s in enumerate(S[2:],2):

    # 2文字→1文字

    x = dp_2[i-1] + 1

    # 1文字→1文字

    if S[i-1] != S[i]:

        x = max(x,dp_1[i-1] + 1)

    dp_1[i] = x

    

    # 1文字→2文字

    x = dp_1[i-2] + 1

    # 2文字→2文字

    if S[i-3:i-1] != S[i-1:i+1]:

        x = max(x,dp_2[i-2] + 1)

    dp_2[i] = x



answer = max(dp_1[-1], dp_2[-1])

print(answer)
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



# 長さ3以上は使わないとしてよい



S = '$$' + read().rstrip().decode('utf-8')



# 最後の長さ -> 文字列の個数

N = len(S)

INF = 10 ** 9

one = [-INF] * N; one[1] = 0

two = [-INF] * N; two[1] = 0



for i in range(2,N):

    # 2 -> 1

    x = two[i-1] + 1

    # 1 -> 1

    if S[i] != S[i-1]:

        y = one[i-1] + 1

        if x < y:

            x = y

    one[i] = x

    # 1 -> 2

    x = one[i-2] + 1

    # 2 -> 2

    if S[i-1:i+1] != S[i-3:i-1]:

        y = two[i-2] + 1

        if x < y:

            x = y

    two[i] = x



answer = max(one[-1],two[-1])

print(answer)
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
S = input().rstrip()
if len(S) == 1:
    print((1))
    exit()
# n文字目を最後に長さ1,2で見る
INF = 10**10
dp_1 = [-INF] * (len(S))
dp_2 = [-INF] * (len(S))
dp_1[0] = 1
dp_2[1] = 1
if S[0] != S[1]:
    dp_1[1] = 2
for i, s in enumerate(S[2:], 2):
    # 2文字→1文字
    x = dp_2[i - 1] + 1
    # 1文字→1文字
    if S[i - 1] != S[i]:
        x = max(x, dp_1[i - 1] + 1)
    dp_1[i] = x
    # 1文字→2文字
    x = dp_1[i - 2] + 1
    # 2文字→2文字
    if S[i - 3 : i - 1] != S[i - 1 : i + 1]:
        x = max(x, dp_2[i - 2] + 1)
    dp_2[i] = x
answer = max(dp_1[-1], dp_2[-1])
print(answer)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# 長さ3以上は使わないとしてよい
S = "$$" + read().rstrip().decode("utf-8")
# 最後の長さ -> 文字列の個数
N = len(S)
INF = 10**9
one = [-INF] * N
one[1] = 0
two = [-INF] * N
two[1] = 0
for i in range(2, N):
    # 2 -> 1
    x = two[i - 1] + 1
    # 1 -> 1
    if S[i] != S[i - 1]:
        y = one[i - 1] + 1
        if x < y:
            x = y
    one[i] = x
    # 1 -> 2
    x = one[i - 2] + 1
    # 2 -> 2
    if S[i - 1 : i + 1] != S[i - 3 : i - 1]:
        y = two[i - 2] + 1
        if x < y:
            x = y
    two[i] = x
answer = max(one[-1], two[-1])
print(answer)

-input = sys.stdin.readline -sys.setrecursionlimit(10**7) -S = input().rstrip() -if len(S) == 1: -    print((1)) -    exit() -# n文字目を最後に長さ1,2で見る -INF = 10**10 -dp_1 = [-INF] * (len(S)) -dp_2 = [-INF] * (len(S)) -dp_1[0] = 1 -dp_2[1] = 1 -if S[0] != S[1]: -    dp_1[1] = 2 -for i, s in enumerate(S[2:], 2): -    # 2文字→1文字 -    x = dp_2[i - 1] + 1 -    # 1文字→1文字 -    if S[i - 1] != S[i]: -        x = max(x, dp_1[i - 1] + 1) -    dp_1[i] = x -    # 1文字→2文字 -    x = dp_1[i - 2] + 1 -    # 2文字→2文字 -    if S[i - 3 : i - 1] != S[i - 1 : i + 1]: -        x = max(x, dp_2[i - 2] + 1) -    dp_2[i] = x -answer = max(dp_1[-1], dp_2[-1]) +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +# 長さ3以上は使わないとしてよい +S = "$$" + read().rstrip().decode("utf-8") +# 最後の長さ -> 文字列の個数 +N = len(S) +INF = 10**9 +one = [-INF] * N +one[1] = 0 +two = [-INF] * N +two[1] = 0 +for i in range(2, N): +    # 2 -> 1 +    x = two[i - 1] + 1 +    # 1 -> 1 +    if S[i] != S[i - 1]: +        y = one[i - 1] + 1 +        if x < y: +            x = y +    one[i] = x +    # 1 -> 2 +    x = one[i - 2] + 1 +    # 2 -> 2 +    if S[i - 1 : i + 1] != S[i - 3 : i - 1]: +        y = two[i - 2] + 1 +        if x < y: +            x = y +    two[i] = x +answer = max(one[-1], two[-1])