S = input()

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

res = recur_del(S)

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