S = input()
N = len(S)


def f(start, last):
    i = start
    cnt = 1 if start != 0 else 0
    # print(f"i:{i}, cnt:{cnt}, last:{last}")
    while i < N:
        if last != S[i]:
            cnt += 1
            last = S[i]
            i += 1
        else:
            if i + 1 >= N:
                return -1
            cnt += 1
            last = S[i] + S[i + 1]
            i += 2
        # print(f"i:{i}, cnt:{cnt}, last:{last}")
    return cnt


r1 = f(0, "")
r2 = f(2, S[0:2]) if N >= 2 else 0

print(max(r1, r2))
