#!/usr/bin/env python3
import sys
from itertools import groupby


def solve(S: str):
    i = 1
    res_1 = 1
    prev = S[0]
    while i < len(S)-2:
        if S[i] == prev:
            j = 2
        else:
            j = 1
        prev = S[i:i+j]
        res_1 += 1
        i += j

    if i > len(S) - 1:
        pass
    elif i == len(S) - 1:
        if S[i:] == prev:
            res_1 = 0
        else:
            res_1 += 1
    else:
        if S[i] == S[i+1]:
            if S[i:] == prev:
                res_1 = 0
            else:
                res_1 += 1
        else:
            res_1 += 2

    i = 2
    res_2 = 1
    prev = S[0:2]
    while i < len(S)-2:
        if S[i] == prev:
            j = 2
        else:
            j = 1
        prev = S[i:i+j]
        res_2 += 1
        i += j
    if i > len(S) - 1:
        pass
    elif i == len(S) - 1:
        if S[i:] == prev:
            res_2 = 0
        else:
            res_2 += 1
    else:
        if S[i] == S[i+1]:
            if S[i:] == prev:
                res_2 = 0
            else:
                res_2 += 1
        else:
            res_2 += 2
    print(max(res_1,res_2))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()
