s=input()
t=[]
c=0
p=0
i=0
t=""
while i<=len(s)-2:
    if p==0:
        if s[i]!=s[i+1]:
            c+=2
            i+=2
            p=1
        else:
            t+=s[i]
            i+=1
    else:
        if len(t)==0:
            p=0
        else:
            if t[-1]!=s[i]:
                c+=2
                i+=1
                t=t[:len(t)]
            else:
                p=0   
print(c)