S = input()

N = len(S)

count = 0
while(1):
    f=0
    for i in range(N-1):
        if S[i] != S[i+1]:
            f=1
            count += 2
            if N<=3:
                f=0
                break
            if i == 0:
                S=S[2:]
            if i == 1:
                S=S[0]+S[3:]
            if i == N-2:
                S=S[:N-2]
            N -= 2
            break
    if f == 0:
        break

print(count)