s=list(input())
zero=s.count('0')
iti=s.count('1')
hatena=s.count('?')
if(hatena==0):
	print(abs(zero-iti))
elif(zero-iti==0):
	print(1)
elif(zero+iti<=hatena):
		print(abs(zero-iti))
elif(len(s)%2==0):
	print(abs(zero-iti)+1)
elif((len(s)%2)!=0):
	print(abs(zero-iti)-1)
