from collections import deque

s=deque(eval(input()))

A=deque()

for i in range(len(s)):

  a=s.popleft()

  if a=="B":

    if len(A)>0:

      A.pop()

  else:

    A.append(a)

print(("".join(A)))
t=""

for x in eval(input()):

    if x=="B":

      t=t[:-1]

    else:t+=x

print(t)
from collections import deque

s = deque(eval(input()))
A = deque()
for i in range(len(s)):
    a = s.popleft()
    if a == "B":
        if len(A) > 0:
            A.pop()
    else:
        A.append(a)
print(("".join(A)))

t = ""
for x in eval(input()):
    if x == "B":
        t = t[:-1]
    else:
        t += x
print(t)

-from collections import deque - -s = deque(eval(input())) -A = deque() -for i in range(len(s)): -    a = s.popleft() -    if a == "B": -        if len(A) > 0: -            A.pop() +t = "" +for x in eval(input()): +    if x == "B": +        t = t[:-1] -        A.append(a) -print(("".join(A))) +        t += x +print(t)