from sys import stdin
def main():
    s = stdin.readline().strip()
    s += '0'
    ans = k = r = 0
    p = '0'
    for c in s:
        if c == p:
            k += 1
        else:
            if r and k % 3 == 2:
                ans += 1
                r = 0
            else:
                r = k % 3 == 2
            ans += k / 3 * 2 + (k % 3 > 0)
            k = 1
            p = c
    print ans
main()
