S = list(input())
N = len(S)
S = [None] + S + [None]
nxt = [i + 1 for i in range(N+2)]
prv = [i - 1 for i in range(N+2)]

def remove(i):
    prv[nxt[i]] = prv[i]
    nxt[prv[i]] = nxt[i]

def dump():
    print(S)
    print(nxt)
    print(prv)
    print()

count = 0
while(True):
    i = nxt[0]
    j = nxt[i]
    removed = False
    while(True):
        #print(i, j)
        #dump()
        if S[i] == None or S[j] == None:
            break
        if S[i] == S[j]:
            i = j
            j = nxt[j]
        else:
            remove(i)
            remove(j)
            removed = True
            count += 2
            i = nxt[prv[i]]
            j = nxt[i]
    if not removed:
        break
#dump()
print(count)