import re

s = eval(input())

for _ in range(s.count('B')):

    s = re.sub('.?B', '', s, 1)

print(s)
s=eval(input())

while'B'in s:

    s=s[s[0]=='B':].replace('0B','').replace('1B','')

print(s)
import re

s = eval(input())
for _ in range(s.count("B")):
    s = re.sub(".?B", "", s, 1)
print(s)

s = eval(input())
while "B" in s:
    s = s[s[0] == "B" :].replace("0B", "").replace("1B", "")
print(s)

-import re - -for _ in range(s.count("B")): -    s = re.sub(".?B", "", s, 1) +while "B" in s: +    s = s[s[0] == "B" :].replace("0B", "").replace("1B", "")