S = input()
dp = [-1]*len(S)
l = len(S)
ans = 1
count = 1
for i in range(1, l):
    if S[i] != S[i-1]:
        ans += 1
        count = 1
    else:
        count += 1
        if count % 3 != 2:
            ans += 1
        elif i == l - 1:
            ans += 1
print(ans)
