S = list(eval(input()))

N = len(S)



# n文字まで見て最後が1文字か2文字化

dp_1 = [0] * N

dp_2 = [0] * N

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):

    # dp_1

    # 2 -> 1

    tmp = dp_2[i - 1] + 1

    # 1 -> 1

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

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

    dp_1[i] = tmp



    # dp_2

    # 1->2

    tmp = dp_1[i - 2] + 1

    # 2->2

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

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

    dp_2[i] = tmp



print((max(dp_1[-1], dp_2[-1])))

import sys



sys.setrecursionlimit(10 ** 6)

INF = float("inf")

MOD = 10 ** 9 + 7





def input():

    return sys.stdin.readline().strip()





def main():

    S = eval(input())

    N = len(S)



    # n文字まで見て最後が1文字か2文字か

    dp_1 = [0] * N

    dp_2 = [0] * N

    dp_1[0] = 1

    dp_2[1] = 1

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

        dp_1[1] = 2



    for i in range(2, N):

        # 2 -> 1

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



        # 2 -> 2

        if S[i - 2 : i] != S[i : i + 2]:

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



        # 1 -> 2

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



        # 1 -> 1

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

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



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

    print(ans)





if __name__ == "__main__":

    main()

S = list(eval(input()))
N = len(S)
# n文字まで見て最後が1文字か2文字化
dp_1 = [0] * N
dp_2 = [0] * N
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):
    # dp_1
    # 2 -> 1
    tmp = dp_2[i - 1] + 1
    # 1 -> 1
    if S[i - 1] != S[i]:
        tmp = max(tmp, dp_1[i - 1] + 1)
    dp_1[i] = tmp
    # dp_2
    # 1->2
    tmp = dp_1[i - 2] + 1
    # 2->2
    if S[i - 3 : i - 1] != S[i - 1 : i + 1]:
        tmp = max(tmp, dp_2[i - 2] + 1)
    dp_2[i] = tmp
print((max(dp_1[-1], dp_2[-1])))

import sys

sys.setrecursionlimit(10**6)
INF = float("inf")
MOD = 10**9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    S = eval(input())
    N = len(S)
    # n文字まで見て最後が1文字か2文字か
    dp_1 = [0] * N
    dp_2 = [0] * N
    dp_1[0] = 1
    dp_2[1] = 1
    if S[0] != S[1]:
        dp_1[1] = 2
    for i in range(2, N):
        # 2 -> 1
        dp_1[i] = max(dp_2[i - 1] + 1, dp_1[i])
        # 2 -> 2
        if S[i - 2 : i] != S[i : i + 2]:
            dp_2[i] = max(dp_2[i - 2] + 1, dp_2[i])
        # 1 -> 2
        dp_2[i] = max(dp_1[i - 2] + 1, dp_2[i])
        # 1 -> 1
        if S[i - 1] != S[i]:
            dp_1[i] = max(dp_1[i - 1] + 1, dp_1[i])
    ans = max(dp_1[-1], dp_2[-1])
    print(ans)


if __name__ == "__main__":
    main()

-S = list(eval(input())) -N = len(S) -# n文字まで見て最後が1文字か2文字化 -dp_1 = [0] * N -dp_2 = [0] * N -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): -    # dp_1 -    # 2 -> 1 -    tmp = dp_2[i - 1] + 1 -    # 1 -> 1 -    if S[i - 1] != S[i]: -        tmp = max(tmp, dp_1[i - 1] + 1) -    dp_1[i] = tmp -    # dp_2 -    # 1->2 -    tmp = dp_1[i - 2] + 1 -    # 2->2 -    if S[i - 3 : i - 1] != S[i - 1 : i + 1]: -        tmp = max(tmp, dp_2[i - 2] + 1) -    dp_2[i] = tmp -print((max(dp_1[-1], dp_2[-1]))) +import sys + +sys.setrecursionlimit(10**6) +INF = float("inf") +MOD = 10**9 + 7 + + +def input(): +    return sys.stdin.readline().strip() + + +def main(): +    S = eval(input()) +    N = len(S) +    # n文字まで見て最後が1文字か2文字か +    dp_1 = [0] * N +    dp_2 = [0] * N +    dp_1[0] = 1 +    dp_2[1] = 1 +    if S[0] != S[1]: +        dp_1[1] = 2 +    for i in range(2, N): +        # 2 -> 1 +        dp_1[i] = max(dp_2[i - 1] + 1, dp_1[i]) +        # 2 -> 2 +        if S[i - 2 : i] != S[i : i + 2]: +            dp_2[i] = max(dp_2[i - 2] + 1, dp_2[i]) +        # 1 -> 2 +        dp_2[i] = max(dp_1[i - 2] + 1, dp_2[i]) +        # 1 -> 1 +        if S[i - 1] != S[i]: +            dp_1[i] = max(dp_1[i - 1] + 1, dp_1[i]) +    ans = max(dp_1[-1], dp_2[-1]) +    print(ans) + + +if __name__ == "__main__": +    main()