s = input()

zCount = s.count("0")
oCount = s.count("1")
qCount = s.count("?")
diff = abs(zCount - oCount)
# if zCount > oCount:
#     diff = zCount - oCount
# else:
#     diff = oCount - zCount 
if qCount % 2 == 0:
    print(diff)
else:
    diff += 1
    print(diff)