l = input()
l1 =l
l2 =l1
p=0
while(p!=-1):
    l1 = l1.replace("01","")
    p=l1.find("01")
p=0
while(p!=-1):
    l1=l1.replace("10","")
    p=l1.find("10")
p=0
while(p!=-1):
    l2 = l2.replace("01","")
    p=l2.find("01")
p=0
while(p!=-1):
    l2=l2.replace("10","")
    p=l2.find("10")

print(max(len(l)-len(l1),len(l)-len(l2)))