from collections import deque
S = input()
stack = deque([])
c = 0
for s in S:
  if len(stack)==0:
    stack.append(s)
  elif stack[-1]==s:
    stack.append(s)
  else:
    stack.pop()
    c += 2
print(c) from collections import deque S = input() S input() input stack = deque([]) stack deque([]) deque [] c = 0 c 0 for s in S:
  if len(stack)==0:
    stack.append(s)
  elif stack[-1]==s:
    stack.append(s)
  else:
    stack.pop()
    c += 2 s S if len(stack)==0:
    stack.append(s)
  elif stack[-1]==s:
    stack.append(s)
  else:
    stack.pop()
    c += 2 len(stack)==0 len(stack) len stack 0 stack.append(s) stack.append stack append s elif stack[-1]==s:
    stack.append(s)
   stack[-1]==s stack[-1] stack -1 s stack.append(s) stack.append stack append s stack.pop() stack.pop stack pop c += 2 c 2 print(c) print c stack = deque([]) deque([]) stack c = 0 0 c c += 2 2 c S = input() input() S
from collections import deque
S = input()
stack = deque([])
c = 0
for s in S:
  if len(stack)==0:
    stack.append(s)
  elif stack[-1]==s:
    stack.append(s)
  else:
    stack.pop()
    c += 2
print(c)