S=list(input())

c=0
cc=3
tmp=[]
while c!=cc:
    cc=c
    for i in range(len(S)-1):
        if S[i]!=S[i+1] and S[i]!='2':
            S[i]='2'
            S[i+1]='2'
            c+=2

    while S:
        e=S.pop()
        if e!='2':
            tmp.append(e)
    while tmp:
        S.append(tmp.pop())

print(c)