s = input()
zero = s.count('0')
one = s.count('1')
que = s.count('?')
diff = abs(zero-one)
if diff - que < 0:
    a = diff - que
    print(a % 2)
elif diff - que > 0:
    print(diff-que)
else:
    print(0)