S = input()
print(S)
stack = []
ans = 0
for c in S:
    if stack and stack[0] != c:
        print("stack={}, c={} pop!".format(stack, c))
        stack.pop()
        ans += 2
    else:
        print("stack={}, c={} append!".format(stack, c))
        stack.append(c)
#     print("c={0}, st={1}".format(c, stack))
print(ans)