def sonu(a,count,pivot):
    if(a[pivot]!=a[pivot+1]):
        a.pop(pivot)
        a.pop(pivot)
        pivot=0
        count+=1
        if(len(set(a))!=1 and len(a)!=0):
            sonu(a,count,pivot)
        else:
            print(count*2)
        

    else:
        
        pivot+=1
        if(len(set(a))!=1):
            sonu(a,count,pivot)
        else:
            print(count*2)
        
    
    




a=list(input())
if(len(a)==1):
    print(0)
else:
    count=0
    pivot=0
    sonu(a,count,pivot)
            
