S = eval(input())

ans = []

for s in S:

    if s=='B' and ans:

        ans.pop(-1)

    elif s!='B':

        ans.append(s)

print((''.join(ans)))
import sys

INF = 1 << 60

MOD = 10**9 + 7 # 998244353

sys.setrecursionlimit(2147483647)

input = lambda:sys.stdin.readline().rstrip()

def resolve():

    stack = []

    for c in eval(input()):

        if c != 'B':

            stack.append(c)

        else:

            if stack:

                stack.pop()

    print((''.join(stack)))

resolve()
S = eval(input())
ans = []
for s in S:
    if s == "B" and ans:
        ans.pop(-1)
    elif s != "B":
        ans.append(s)
print(("".join(ans)))

import sys

INF = 1 << 60
MOD = 10**9 + 7  # 998244353
sys.setrecursionlimit(2147483647)
input = lambda: sys.stdin.readline().rstrip()


def resolve():
    stack = []
    for c in eval(input()):
        if c != "B":
            stack.append(c)
        else:
            if stack:
                stack.pop()
    print(("".join(stack)))


resolve()

-S = eval(input()) -ans = [] -for s in S: -    if s == "B" and ans: -        ans.pop(-1) -    elif s != "B": -        ans.append(s) -print(("".join(ans))) +import sys + +INF = 1 << 60 +MOD = 10**9 + 7  # 998244353 +sys.setrecursionlimit(2147483647) +input = lambda: sys.stdin.readline().rstrip() + + +def resolve(): +    stack = [] +    for c in eval(input()): +        if c != "B": +            stack.append(c) +        else: +            if stack: +                stack.pop() +    print(("".join(stack))) + + +resolve()