import re


S = input()
L = len(S)

is_break = False

while len(S) > 1:
    S = re.sub('(01)+', '', S)
    S = re.sub('(10)+', '', S)
    try:
        S.find('01')
        S.find('10')
    except:
        is_break = True
    if is_break:
        break

print(L - len(S))
