from collections import deque



s = eval(input())



ans = deque()



for i in s:

    if i == 'B':

        if ans != deque([]):

            ans.pop()

    else:

        ans.append(i)



ans = "".join(list(ans))



print(ans)
s = []



for i in eval(input()):

    if i == 'B':

        s = s[:-1]

    else:

        s += i



print(("".join(s)))
from collections import deque

s = eval(input())
ans = deque()
for i in s:
    if i == "B":
        if ans != deque([]):
            ans.pop()
    else:
        ans.append(i)
ans = "".join(list(ans))
print(ans)

s = []
for i in eval(input()):
    if i == "B":
        s = s[:-1]
    else:
        s += i
print(("".join(s)))

-from collections import deque - -s = eval(input()) -ans = deque() -for i in s: +s = [] +for i in eval(input()): -        if ans != deque([]): -            ans.pop() +        s = s[:-1] -        ans.append(i) -ans = "".join(list(ans)) -print(ans) +        s += i +print(("".join(s)))