sent = str(input())
tmpsent = sent
lis = []
ss = ""
ss2 = ""
for i in range(int(len(sent) / 2)):
    ss = "0" + ss + "1"
    ss2 = "1" + ss2 + "0"
    lis.append(ss)
    lis.append(ss2)
lis.reverse()
loop = True
while loop:
    loop = False
    for l in lis:
        if tmpsent != tmpsent.replace(l, ''):
            tmpsent = tmpsent.replace(l , '')
            loop = True
print(len(sent) - len(tmpsent))