s =input()
N = len(s)
cont = True
while cont==True:
    s = s.split('10')
    a = ''
    for i in s:
        a=a+i
    if s[0] == a:
        cont = False
        s = a
    else:
        s = a 
cont = True
while cont:
    s = s.split('01')
    a = ''
    for i in s:
        a=a+i
    if s[0] == a:
        cont = False
    else:
        s = a
N2 = len(a)
print(N-N2)