from collections import deque



S=eval(input())

d=deque()

for s in S:

  if s == 'B':

    if len(d) != 0:

      d.pop()

  else:

    d.append(s)

print((''.join(d)))
S=eval(input())

d=[]

for s in S:

  if s == 'B':

    if d:

      d.pop()

  else:

    d.append(s)

print((''.join(d)))
from collections import deque

S = eval(input())
d = deque()
for s in S:
    if s == "B":
        if len(d) != 0:
            d.pop()
    else:
        d.append(s)
print(("".join(d)))

S = eval(input())
d = []
for s in S:
    if s == "B":
        if d:
            d.pop()
    else:
        d.append(s)
print(("".join(d)))

-from collections import deque - -d = deque() +d = [] -        if len(d) != 0: +        if d: