str = list(input())
check = 0   #
ans = 0  # 取り除いた数
odd = 0

while True:
    check = 0

    if odd == 0:
        last = str[0]
        for j in range(len(str) - 1):
            if last != str[j + 1]:
                str.pop(j)
                str.pop(j)
                check = 1
                ans += 2
                break
            last = str[j + 1]
        odd = 1
    else:
        last = str[len(str)-1]
        for j in reversed(range(len(str) - 1)):
            if last != str[j]:
                str.pop(j)
                str.pop(j)
                check = 1
                ans += 2
                break
            last = str[j]
        odd = 0

    if check == 0:
        break
    if str == []:
        break

print(ans)
