s = [int(i) for i in input()]
size = len(s)

def operation(strings):
    rest = []
    count = 0

    for i in range(len(strings)-1) :
        if strings[i] != strings[i+1] and count - 1  != i :
            rest.extend(strings[count:i])
            count = i + 2

    rest.extend(strings[count:])
    return rest 


while True :
    
    s = operation(s)
    if sum(s)  == len(s)  or sum(s)== 0:
        break
    else : continue
    
    
ans = size - len(s)
print(ans)