S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

s=S()
ans=0
ss=""
ind=0
remove=False
loop=True
#print(s)
while loop:
    ind_max=len(s)-1
    if(ind>=ind_max):
        s=ss
        #print()
        #print(s)
        ss=""
        ind=0
        ind_max=len(s)-1
        if not remove:
            loop=False
        remove=False
        continue
    if s[ind]!=s[ind+1]:
        #print("↑↑",end="")
        ans+=2
        ind+=1
        remove=True
    else:
        #print(" ",end="")
        ss+=s[ind]
        if ind==ind_max:
            ss+=s[ind+1]
    ind+=1
print(ans)
