import collections
S = input()
T = collections.deque([])
for s in S:
    T.append(s)
stack = []
for t in T:
    if not stack:
        stack.append(t)
    else:
        if stack[-1] != t:
            stack.pop()
        else:
            stack.append(t)
print(len(T)-len(stack)) import collections collections S = input() S input() input T = collections.deque([]) T collections.deque([]) collections.deque collections deque [] for s in S:
    T.append(s) s S T.append(s) T.append T append s stack = [] stack [] for t in T:
    if not stack:
        stack.append(t)
    else:
        if stack[-1] != t:
            stack.pop()
        else:
            stack.append(t) t T if not stack:
        stack.append(t)
    else:
        if stack[-1] != t:
            stack.pop()
        else:
            stack.append(t) not stack stack stack.append(t) stack.append stack append t if stack[-1] != t:
            stack.pop()
        else:
            stack.append(t) stack[-1] != t stack[-1] stack -1 t stack.pop() stack.pop stack pop stack.append(t) stack.append stack append t print(len(T)-len(stack)) print len(T)-len(stack) len(T) len T len(stack) len stack T = collections.deque([]) collections.deque([]) T S = input() input() S stack = [] [] stack
import collections
S = input()
T = collections.deque([])
for s in S:
    T.append(s)
stack = []
for t in T:
    if not stack:
        stack.append(t)
    else:
        if stack[-1] != t:
            stack.pop()
        else:
            stack.append(t)
print(len(T)-len(stack))
