import sys
sys.setrecursionlimit(5000)
S = input()

def recur_del(s):
  s = s.replace('01','A')
  s = s.replace('10','A')
  lst = s.split('A')
  s2 = ''.join(lst) 
  if len(s) == len(s2):
    return s2
  return recur_del(s2)

res = recur_del(S)

print(len(S) - len(res))
