import copy

S = str(input())
lenS = len(S)
S2 = copy.copy(S)

flag = 0
while flag == 0:
  if S.find('10') != -1:
    S = S[:S.find('10')-1] + S[S.find('10')+1:]
  elif S.find('01') != -1:
    S = S[:S.find('01')-1] + S[S.find('01')+1:]
  else:
    flag = 1
lenS_ = len(S)

flag = 0
while flag == 0:
  if S2.find('01') != -1:
    S2 = S2[:S2.find('01')-1] + S2[S2.find('01')+1:]
  elif S.find('10') != -1:
    S2 = S2[:S2.find('10')-1] + S2[S2.find('10')+1:]
  else:
    flag = 1
lenS2_ = len(S2)

if lenS_ < lenS2_:
  print(lenS - lenS_)
else:
  print(lenS - lenS2_)