S = input()

count0 = S.count('0')
#print(count0)
count1 = S.count('1')
#print(count1)
countQ = S.count('?')
#print(countQ)
abs1 = abs(count0 - count1)
#print(abs1)

if abs1 == 0:
  if countQ % 2 == 0:
    print(3)
  else:
    print(1)
else:
  if countQ % 2 == 0:
    print(abs1)
  else:
    print(abs1 + 1)