s=[i for i in input()]
leng=len(s)
flg=True
while flg:
    flg=False
    for i in range(len(s)-1):
        if s[i]!=s[i+1]:
            s.pop(i+1)
            s.pop(i)
            flg=True
            break
print(leng - len(s))     
    