s=eval(input())

ans,skip='',0

for c in reversed(s):

    if c=='B':

        skip+=1

    elif skip:

        skip-=1

    else:

        ans+=c



print((ans[::-1]))

s=eval(input())

stk=[]

for c in s:

    if c in '01':

        stk.append(c)

    elif stk:

        stk.pop()



print((''.join(stk)))

s = eval(input())
ans, skip = "", 0
for c in reversed(s):
    if c == "B":
        skip += 1
    elif skip:
        skip -= 1
    else:
        ans += c
print((ans[::-1]))

s = eval(input())
stk = []
for c in s:
    if c in "01":
        stk.append(c)
    elif stk:
        stk.pop()
print(("".join(stk)))

-ans, skip = "", 0 -for c in reversed(s): -    if c == "B": -        skip += 1 -    elif skip: -        skip -= 1 -    else: -        ans += c -print((ans[::-1])) +stk = [] +for c in s: +    if c in "01": +        stk.append(c) +    elif stk: +        stk.pop() +print(("".join(stk)))