s = input().rstrip()

# start from 1
idx = 0
pata = []
patb = []
pata.append(s[idx])
idx += 1
while idx < len(s):
    pata.append(s[idx])
    idx += 1
    while len(pata) > 1 and pata[-2] == pata[-1]:
        if idx < len(s):
            pata[-1] += s[idx]
            idx += 1
        else:
            last = pata.pop()
            pata[-1] += last

# start from 2
idx = 0
patb = []
patb.append(s[idx:idx+2])
idx += 2
while idx < len(s):
    patb.append(s[idx])
    idx += 1
    while len(patb) > 1 and patb[-2] == patb[-1]:
        if idx < len(s):
            patb[-1] += s[idx]
            idx += 1
        else:
            last = patb.pop()
            patb[-1] += last

print(max(len(pata), len(patb)))