import re,sys

s = str(input())
sl = list(s)

def ltox(s):
    if(len(s) <= 1):
        return (s)
    for i in range(1, len(s)-1):
        if(s[i-1] != s[i] and s[i-1] != 'x'):
            s[i] = 'x'
            s[i-1] = 'x'
    return [i for i in s if i != 'x']


bllx = len(s)
llx = sl.copy()
while True:
    llx = ltox(llx)
    # print(llx)
    if(len(llx) == bllx):
        if(len(llx) == 2 and llx[0] != llx[1]):
            print(len(list(str(s))))
        else:
            print(len(list(str(s)))-len(llx))
        sys.exit()
    else:
        bllx = len(llx)

