S = list(input())
N = len(S)

count = 0
local_count = 0
for i in range(N-3):
    if S[i] == S[i+1]:
        if S[i] == S[i+2]:
            local_count += 1
        elif S[i+2] == S[i+3]:
            S[i+1] = '0'
            S[i+2] = '1'
            count += 1
            count += (local_count)
            local_count = 0
        else:
            local_count += 1
            count += (local_count)
            local_count = 0
for i in range(N-3, N-1):
    if S[i] == S[i+1]:
        S[i+1] = '2'
        count += 1
print(N-count)
