def main():
    s = input()

    def cut(s, init=1):
        cnt = 1

        i = init
        p = s[:init]
        t = ''
        while i < len(s):
            t += s[i]
            if p != t:
                p = t
                t = ''
                cnt += 1
            i += 1

        if t:
            return -1
        else:
            return cnt

    ans = max(
        cut(s, 1),
        cut(s, 2)
    )

    print(ans)


if __name__ == '__main__':
    main()

# 一文字か二文字
