s=list(input())
n1=len(s)

import sys
sys.setrecursionlimit(10**9)

def a(s,n1):
    for i in range(1,len(s)):
        if s[i-1]=="0" and s[i]=="1" or s[i-1]=="1" and s[i]=="0":
            s[i-1]=s[i]="a"
    s=list("".join(s).replace("a",""))
    
    if len(set(s))==1 or s==[]:
        print(n1-len(s))
    else:
        a(s,n1)
a(s,n1)    
