s=input()
from itertools import groupby as gb
l=[len(list(b)) for a,b in gb(list(s))]
pre=0
ans=0
c=[0,0]
px,py=0,0
for x,y in zip(l[::2],l[1::2]):
    x+=px
    if py:
        k=min(x,py);x-=k;py-=k;ans+=k
        if x==0:py+=y;continue
    k=min(x,y);ans+=k;px+=(x-k);py+=(y-k)
print(2*ans+2*min(px,py))