import re


def nchars(s, n):
    assert n > 0
    reg = re.compile("(.)\\1{%d,}" % (n - 1))
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s = s[m.end():]


s = input()
li = list(nchars(s, 2))
r = len(s) - sum((len(i) + 1) // 3 for i in li)
b = []
for i, j in enumerate(li):
    if i < len(li) - 1 and i not in b:
        if li[i] + li[i + 1] in s:
            if (len(li[i]) - 2) % 3 == 0 and (len(li[i + 1]) - 2) % 3 == 0:
                r += 1
                b.append(i + 1)
print(r)
