from sys import stdin
import re

S = stdin.readline().rstrip()

before_S = S

while(True):
    #after_S = S.replace("01", "").replace("10", "")
    after_S = re.sub("(01)+|(10)+", "", S)
    if len(after_S) != len(S):
        S = after_S
    else:
        break

print(len(before_S) - len(S))