s = list(input())
if len(s)==1: print(0);exit()
ans = 0
l,r=0,1
bdr = len(s)-2
while l!=bdr:
    if s[l]!=s[r]:
        ans += 2
        s.pop(l);s.pop(l)
        l,r=0,1
    else:
        l+=1
        r+=1
    bdr = len(s)-2
print(ans + 2*(s[0]!=s[1]))