

#c=list(map(int, input().split()))
#str = "11011010001011"


S = input()
c=list(S)

rm_list = []
i = 0
num = len(c)
while(True):
    try:
        while(True):
            
            #print("-------------")
            #print(i)
            #print(c)
            #print("c[{}]:{}".format(i,c[i]))
            #print("c[{}]:{}".format(i+1,c[i+1]))
            if c[i] != c[i+1]:
                #print("けしたよ")
                c.pop(i+1)
                c.pop(i)
                
                i = 0
                break
            i +=1
    except:
        break
#print("================================")
#print(c)
print(num - len(c))


