s = eval(input())



p = []



for token in list(s):

    if token == "B":

        if not len(p) == 0:

            p.pop()

    else:

        p.append(token)



print(("".join(p)))

# https://atcoder.jp/contests/abc043/tasks/abc043_b

s = list(eval(input()))

result = []

for c in s:

    if c == 'B':

        if len(result) > 0:

            result.pop()

    else:

        result.append(c)



print((''.join(result)))

s = eval(input())
p = []
for token in list(s):
    if token == "B":
        if not len(p) == 0:
            p.pop()
    else:
        p.append(token)
print(("".join(p)))

# https://atcoder.jp/contests/abc043/tasks/abc043_b
s = list(eval(input()))
result = []
for c in s:
    if c == "B":
        if len(result) > 0:
            result.pop()
    else:
        result.append(c)
print(("".join(result)))

-s = eval(input()) -p = [] -for token in list(s): -    if token == "B": -        if not len(p) == 0: -            p.pop() +# https://atcoder.jp/contests/abc043/tasks/abc043_b +s = list(eval(input())) +result = [] +for c in s: +    if c == "B": +        if len(result) > 0: +            result.pop() -        p.append(token) -print(("".join(p))) +        result.append(c) +print(("".join(result)))