s = list(input())
l = len(s)

mae= s[0]
re = 0
tot = []
for i in range(1, l):
    re += 1
    if mae != s[i]:
        tot.append(re)
        re = 0
        mae = s[i]
    else:
        mae = s[i]
tot.append(max(re, 1))

ans = 0
lt = len(tot)
flag = False

for i in range(lt):
    n = tot[i]
    if n == 2:
        ans += 1
    else:
        ans += (n+2)//2
    if flag:
        if n%6 == 2:
            ans += 1
            flag = False
        else:
            flag = False
    else:
        if n%6 == 2:
            flag = True

print(ans)
    