import sys

sys.setrecursionlimit(10 ** 7)

S = ['0'] + list(eval(input()))



def g(i):

    if i == 0:

        return 0

    if i == 1:

            return 1

    if i == 2:

        if S[2] == S[1]:

            return 1

        else:

            return 2     



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

        return g(i - 3) + 2

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

        return g(i - 1) + 1

# print (len(S) - 1)

print((g(len(S) - 1)))
S = ['0'] + list(eval(input()))



ans_lst = [0] * (len(S) + 10)

ans_lst[0] = 0

ans_lst[1] = 1

ans_lst[2] = 1 if S[2] == S[1] else 2



for i in range(3, len(S)):

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

        ans_lst[i] = max(ans_lst[i], ans_lst[i - 3] + 2)

    else:

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



print((ans_lst[len(S) - 1]))
import sys

sys.setrecursionlimit(10**7)
S = ["0"] + list(eval(input()))


def g(i):
    if i == 0:
        return 0
    if i == 1:
        return 1
    if i == 2:
        if S[2] == S[1]:
            return 1
        else:
            return 2
    if S[i] == S[i - 1]:
        return g(i - 3) + 2
    if S[i] != S[i - 1]:
        return g(i - 1) + 1


# print (len(S) - 1)
print((g(len(S) - 1)))

S = ["0"] + list(eval(input()))
ans_lst = [0] * (len(S) + 10)
ans_lst[0] = 0
ans_lst[1] = 1
ans_lst[2] = 1 if S[2] == S[1] else 2
for i in range(3, len(S)):
    if S[i] == S[i - 1]:
        ans_lst[i] = max(ans_lst[i], ans_lst[i - 3] + 2)
    else:
        ans_lst[i] = max(ans_lst[i], ans_lst[i - 1] + 1)
print((ans_lst[len(S) - 1]))

-import sys - -sys.setrecursionlimit(10**7) - - -def g(i): -    if i == 0: -        return 0 -    if i == 1: -        return 1 -    if i == 2: -        if S[2] == S[1]: -            return 1 -        else: -            return 2 +ans_lst = [0] * (len(S) + 10) +ans_lst[0] = 0 +ans_lst[1] = 1 +ans_lst[2] = 1 if S[2] == S[1] else 2 +for i in range(3, len(S)): -        return g(i - 3) + 2 -    if S[i] != S[i - 1]: -        return g(i - 1) + 1 - - -# print (len(S) - 1) -print((g(len(S) - 1))) +        ans_lst[i] = max(ans_lst[i], ans_lst[i - 3] + 2) +    else: +        ans_lst[i] = max(ans_lst[i], ans_lst[i - 1] + 1) +print((ans_lst[len(S) - 1]))