from collections import Counter
n = dict(Counter(list(input())))
if not '0' in n:
    n['0'] = 0
if not '1' in n:
    n['1'] = 0

if n['?'] % 2 == 0:
    print(abs(n['1'] - n['0']))
else:
    print(abs(n['1'] - n['0']) - 1)