AtCoder Beginner Contest 043 - Unhappy Hacking (ABC Edit)

Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key.
To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string:
 - The 0 key: a letter 0 will be inserted to the right of the string.
 - The 1 key: a letter 1 will be inserted to the right of the string.
 - The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter 0 stands for the 0 key, the letter 1 stands for the 1 key and the letter B stands for the backspace key. What string is displayed in the editor now?

-----Constraints-----
 - 1 ≦ |s| ≦ 10 (|s| denotes the length of s)
 - s consists of the letters 0, 1 and B.
 - The correct answer is not an empty string.

-----Input-----
The input is given from Standard Input in the following format:
s

-----Output-----
Print the string displayed in the editor in the end.

-----Sample Input-----
01B0

-----Sample Output-----
00

Each time the key is pressed, the string in the editor will change as follows: 0, 01, 0, 00.

Difficulty: EASY

Starter code:

Solutions:
s = input()
res = ''
for x in s:
	if x == 'B':
		res = res[:-1]
	else:
		res += x
print(res)


s = input()
res = ''
for c in list(s):
	if c == 'B':
		if len(res) > 0:
			res = res[:-1]
	else:
		res += c
print(res)


S = input()
ans = ''
for s in S:
	if s == 'B':
		if ans:
			ans = ans[:-1]
	else:
		ans += s
print(ans)


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


S = input()
a = []
for s in S:
	if s == 'B':
		if a:
			a.pop()
	else:
		a.append(s)
print(*a, sep='')


a = input()
s = ''
for i in a:
	if i == 'B':
		s = s[:-1]
	else:
		s += i
print(s)


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


s = str(input())
l = []
for i in s:
	if i == '0' or i == '1':
		l.append(i)
	elif i == 'B' and len(l) != 0:
		l.pop(len(l) - 1)
print(*l, sep='')


s = input()
ans = s
while 'B' in ans:
	ans = ans.lstrip('B').replace('0B', '').replace('1B', '')
print(ans)


s = input()
ans = []
for i in s:
	if i == 'B':
		if ans != []:
			ans.pop(-1)
	else:
		ans.append(i)
print(''.join(ans))


n = ''
for i in input():
	n = n[:-1] if i == 'B' else n + i
print(n)


s = input()
numB = 0
r = ''
for i in range(len(s))[::-1]:
	if s[i] == 'B':
		numB = numB + 1
		continue
	if numB > 0 and (s[i] == '0' or s[i] == '1'):
		numB = numB - 1
		continue
	r = r + s[i]
print(''.join(list(reversed(r))))


import re
s = input()
for _ in range(s.count('B')):
	s = re.sub('(^|[01])B', '', s)
print(s)


a = ''
for c in input():
	if c == 'B':
		if len(a) > 0:
			a = a[:-1]
	else:
		a += c
print(a)


s = input()
len_s = len(s)
text = ''
for i in range(len_s):
	if s[i] == '0':
		text += '0'
	elif s[i] == '1':
		text += '1'
	elif text == '':
		pass
	else:
		text = text[:-1]
print(text)


s = input()
a = []
for c in s:
	if c in ['0', '1']:
		a.append(c)
	elif len(a) != 0:
		a.pop()
print(''.join(a))


s = input()
output = ''
for i in s:
	if i == 'B':
		output = output[:-1]
	else:
		output += i
print(output)


s = input()
a = ''
for x in s:
	if x == 'B':
		if len(a) > 0:
			a = a[:-1]
	else:
		a += x
print(a)


s = input()
S = ''
for i in s:
	if 'B' in i:
		S = S[:len(S) - 1]
		continue
	S += i
print(S)


s = input()
tmp = ''
for i in range(len(s)):
	if s[i] == 'B':
		tmp = tmp[:-1]
	else:
		tmp += s[i]
print(tmp)


a = input()
b = ''
for elem in a:
	if elem == '1':
		b += '1'
	elif elem == '0':
		b += '0'
	else:
		b = b[:-1]
print(b)


s = input()
l = []
for i in range(len(s)):
	if s[i] == '0':
		l.append('0')
	elif s[i] == '1':
		l.append('1')
	elif l == []:
		continue
	else:
		del l[-1]
print(''.join(l))


S = input()
A = []
for c in S:
	if c == 'B':
		if A:
			A.pop()
	else:
		A.append(c)
print(''.join(A))


buf = ''
for c in input():
	if c == 'B':
		buf = buf[:-1]
	else:
		buf += c
print(buf)


a = []
for c in input():
	if c in '01':
		a.append(c)
	else:
		a = a[:-1]
print(''.join(a))


s = ''
for i in input():
	if i == '0':
		s += '0'
	elif i == '1':
		s += '1'
	else:
		s = s[:-1]
print(s)


S = str(input())
ans = []
for i in range(len(S)):
	if S[i] == 'B':
		if ans == []:
			continue
		else:
			ans = ans[:-1]
	else:
		ans.append(S[i])
for i in range(len(ans)):
	print(ans[i], end='')


s = ''
for c in input():
	s = s + c if c == '0' or c == '1' else s[:-1]
print(s)


s = input()
ans = ''
for k in s:
	if k == 'B':
		if ans:
			ans = ans[:-1]
	else:
		ans += k
print(ans)


a = ''
for x in input():
	a = (a + x, a[:-1])[x > 'A']
print(a)


s = ''
for c in input():
	s = [s + c, s[:-1]][c > '1']
print(s)


S = list(input())
ans = []
for s in S:
	if s == 'B':
		if len(ans) > 0:
			del ans[-1]
	else:
		ans.append(s)
print(''.join(ans))


w = []
for c in input():
	if c == 'B':
		if len(w) != 0:
			w.pop()
	else:
		w.append(c)
print(''.join(w))


s = input()
ans = ''
for c in s:
	if c == '0':
		ans += '0'
	elif c == '1':
		ans += '1'
	else:
		ans = ans[:len(ans) - 1]
print(ans)


s = input()
ans = ''
for char in s:
	if char == '0':
		ans += '0'
	if char == '1':
		ans += '1'
	if char == 'B':
		ans = ans[:-1]
print(ans)


s = input()
ans = ''
for si in s:
	if si == 'B':
		ans = ans[:-1]
	else:
		ans += si
print(ans)


S = list(input())
R = ''
for s in S:
	if s == 'B':
		R = R[:-1]
	else:
		R = R + s
print(R)


s = input()
res = ''
for i in range(len(s)):
	if s[i] == '1' or s[i] == '0':
		res += s[i]
	elif s[i] == 'B' and len(res) != 0:
		res = res[:-1]
print(res)


s = input()
ans = ''
for c in s:
	if c != 'B':
		ans += c
	else:
		ans = ans[:-1]
print(ans)


S = input()
ans = ''
for i in S:
	if i == 'B':
		ans = ans[0:-1]
	else:
		ans += i
print(ans)


s = input()
ans = ''
for char in s:
	if char == 'B':
		if ans == '':
			pass
		else:
			l = len(ans)
			ans = ans[0:l - 1]
	else:
		ans += char
print(ans)


s = input()
ans = ''
for i in s:
	if i == 'B':
		if ans != '':
			ans = ans[:-1]
	else:
		ans += i
print(ans)


s = input()
ans = ''
for char in s:
	if char != 'B':
		ans += char
	elif ans == '':
		pass
	else:
		le = len(ans)
		ans = ans[0:le - 1]
print(ans)


s = input()
ans = ''
for x in s:
	if x == 'B':
		ans = ans[:-1]
	else:
		ans += x
print(ans)


a = ''
for i in input():
	if i == 'B':
		if a != '':
			a = a[:len(a) - 1]
	else:
		a += i
print(a)


s = input()
t = ''
for c in s:
	if c != 'B':
		t += c
	elif t:
		t = t[0:-1]
print(t)


s = input()
ans = ''
for i in s:
	if i == '0' or i == '1':
		ans += i
	else:
		ans = ans[:-1]
print(ans)


s = input()
ans = []
for i in range(len(s)):
	if s[i] == 'B':
		if ans:
			ans.pop()
	else:
		ans.append(s[i])
print(''.join(ans))


s = input()
a = ''
for _ in s:
	if _ == 'B':
		a = a[:-1]
	else:
		a += _
print(a)


import re
s = input()
while 'B' in s:
	s = s.lstrip('B')
	s = re.sub('[0,1]B', '', s)
print(s)


import re
s = input()
while 'B' in s:
	s = re.sub('^B+', '', s)
	s = re.sub('[01]B', '', s)
print(s)


ans = []
for i in input():
	if i == 'B':
		if len(ans):
			del ans[-1]
	else:
		ans.append(i)
print(''.join(ans))


res = ''
for i in input():
	if i == 'B':
		res = res[:-1]
	else:
		res += i
print(res)


s = input()
ans = ''
for _ in s:
	if _ == 'B':
		ans = ans[:-1]
	else:
		ans += _
print(ans)


i = input()
a = ''
for x in i:
	if x == 'B':
		a = a[:-1]
	else:
		a += x
print(a)


opperations = list(input())
display_stack = []
for opperation in opperations:
	if opperation == 'B':
		if display_stack:
			display_stack.pop()
	else:
		display_stack.append(opperation)
print(''.join(display_stack))


s = input()
ans = ''
for _ in range(len(s)):
	if s[0] == '0':
		ans += '0'
		s = s[1:]
	elif s[0] == '1':
		ans += '1'
		s = s[1:]
	else:
		s = s[1:]
		ans = ans[:-1]
print(ans)


def answer(s: str) -> str:
	result = ''
	for c in s:
		if c == 'B':
			result = result[:-1]
		else:
			result += c
	return result

def main():
	s = input()
	print(answer(s))

def __starting_point():
	main()
__starting_point()


t = ''
for x in input():
	if x == 'B':
		t = t[:-1]
	else:
		t += x
print(t)


S = input()
ret = ''
for i in range(len(S)):
	if S[i] == '0':
		ret += '0'
	elif S[i] == '1':
		ret += '1'
	else:
		ret = ret[:-1]
print(ret)


s = input()
lis = []
for c in s:
	if c == 'B':
		if len(lis):
			lis = lis[:-1]
		else:
			continue
	else:
		lis.append(int(c))
for i in lis:
	print(i, end='')
print()


a = list(input())
b = ''
for i in a:
	if i == 'B':
		b = b[:len(b) - 1]
	else:
		b += i
print(b)


s = input()
ans = ''
for x in s:
	if x != 'B':
		ans += x
	elif x != '':
		ans = ans[:-1]
print(ans)


S = input()
ret = ''
for i in S:
	if i == 'B':
		ret = ret[:-1]
	else:
		ret += i
print(ret)


first_str = input()
input_list = list(first_str)
total_list = list()
for i in input_list:
	if i == '0':
		total_list.append('0')
	elif i == '1':
		total_list.append('1')
	elif not total_list:
		pass
	else:
		total_list.pop(-1)
total = ''.join([str(_) for _ in total_list])
print(total)


s = input()
x = ''
for i in s:
	if i == 'B':
		if x != '':
			x = x[:-1]
	else:
		x += i
print(x)


s = []
for c in input():
	if c == 'B':
		s and s.pop()
	else:
		s.append(c)
print(''.join(s))


s = list(input())
ans = list()
for i in s:
	if i == '0':
		ans.append(0)
	elif i == '1':
		ans.append(1)
	else:
		try:
			ans.pop(-1)
		except:
			pass
for i in ans:
	print(i, end='')
print()


ans = ''
for key in input():
	if key != 'B':
		ans += key
	else:
		ans = ans[:-1]
print(ans)


s = input()
t = ''
for v in s:
	if v == 'B':
		t = t[:-1]
	else:
		t = t + v
print(t)


from collections import deque
q = deque()
s = input()
for operation in s:
	if operation == '0':
		q.append('0')
	elif operation == '1':
		q.append('1')
	elif operation == 'B':
		try:
			q.pop()
		except IndexError:
			pass
answer = ''
for i in q:
	answer = answer + i
print(answer)


line = input()
S = ''
for i in line:
	if i == 'B':
		S = S[:-1]
	else:
		S += i
print(S)


s = input()
out = ''
for c in s:
	if c != 'B':
		out += c
	else:
		out = out[:-1]
print(out)


s = input()
ans = ''
for a in s:
	if a == '0' or a == '1':
		ans += a
	else:
		ans = ans[:-1]
print(ans)


s = input()
r = ''
for c in s:
	if c == 'B':
		r = r[:-1]
	else:
		r += c
print(r)


n = []
for i in input():
	if i == 'B':
		if n:
			n.pop()
	else:
		n.append(i)
print(*n, sep='')


s = input()
data = []
for i in range(len(s)):
	if s[i] == '0':
		data.append('0')
	elif s[i] == '1':
		data.append('1')
	elif len(data) == 0:
		continue
	else:
		data.pop()
print(*data, sep='')


a = input()
b = ''
for i in a:
	if i == 'B':
		b = b[:-1]
	else:
		b += i
print(b)


s = input()
for _ in range(10):
	s = s.replace('0B', '')
	s = s.replace('1B', '')
s = s.replace('B', '')
print(s)


a = input()
test = ''
for i in range(len(a)):
	if a[i] == '0':
		test += '0'
	elif a[i] == '1':
		test += '1'
	elif len(a) == 0:
		pass
	else:
		test = test[:-1]
print(test)


s = input()
e = ''
for i in s:
	if i == 'B':
		e = e[:-1]
	else:
		e += i
print(e)


s = list(input())
w_len = len(s)
word = []
for x in range(w_len):
	if s[x] == 'B':
		if word != []:
			word.pop(-1)
	else:
		word.append(s[x])
result = ''
for y in word:
	result = result + y
print(result)


binaryKeyboard = list(input())
ans = []
for i in binaryKeyboard:
	if i == '0' or i == '1':
		ans.append(i)
	elif len(ans) == 0:
		continue
	else:
		del ans[-1]
print(''.join(ans))


s = input()
a = ''
for i in range(len(s)):
	if s[i] == '0' or s[i] == '1':
		a += s[i]
	else:
		a = a[:-1]
print(a)


from sys import stdin
input = stdin.readline
S = input().strip()
P = ''
for s in S:
	if s == 'B':
		if P != '':
			P = P[:-1]
	else:
		P = P + s
print(P)


s = list(input())
ans = []
for i in range(len(s)):
	if s[i] == '0':
		ans.append('0')
	elif s[i] == '1':
		ans.append('1')
	elif s[i] == 'B' and len(ans) > 0:
		del ans[-1]
print(''.join(ans))


import math
from math import gcd, pi, sqrt
INF = float('inf')
MOD = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10 ** 6)
import itertools
import bisect
from collections import Counter, deque

def i_input():
	return int(input())

def i_map():
	return map(int, input().split())

def i_list():
	return list(i_map())

def i_row(N):
	return [i_input() for _ in range(N)]

def i_row_list(N):
	return [i_list() for _ in range(N)]

def s_input():
	return input()

def s_map():
	return input().split()

def s_list():
	return list(s_map())

def s_row(N):
	return [s_input for _ in range(N)]

def s_row_str(N):
	return [s_list() for _ in range(N)]

def s_row_list(N):
	return [list(s_input()) for _ in range(N)]

def main():
	S = input()
	ans = ''
	for i in S:
		if i != '' and i == 'B':
			ans = ans[:-1]
		if i != 'B':
			ans = ans + i
	print(ans)

def __starting_point():
	main()
__starting_point()


from collections import deque
d = deque()
for c in input():
	if c != 'B':
		d.append(c)
	elif len(d) != 0:
		d.pop()
print(*d, sep='')


S = input()
T = ''
for s in S:
	if s == 'B':
		if T:
			T = T[:-1]
	else:
		T += s
print(T)


l = input()
s = ''
for i in l:
	if i == 'B':
		s = s[:-1]
	else:
		s = s + i
print(s)


a = input()
b = ''
for x in a:
	if x == 'B':
		b = b[:-1]
	else:
		b = b + x
print(b)


s = str(input())
a = ''
for i in s:
	if i != 'B':
		a = a + i
	elif len(a) != 0:
		a = a[0:len(a) - 1]
print(a)


s = ''
for i in input():
	if i == 'B' and s is not None:
		s = s[:-1]
	else:
		s += i
print(s)


S = input()
stack = []
for s in S:
	if not stack and s != 'B':
		stack.append(s)
	elif s == 'B':
		if stack:
			stack.pop()
		else:
			continue
	else:
		stack.append(s)
print(''.join(stack))


s = input()
fin = ''
for c in s:
	if c == '1':
		fin += '1'
	elif c == '0':
		fin += '0'
	elif len(fin) > 0:
		fin = fin[:-1]
print(fin)


x = input()
z = ''
for i in x:
	if i == '0':
		z = z + i
	elif i == '1':
		z = z + i
	elif i == 'B':
		z = z[:-1]
print(z)


s = input()
n = len(s)
ans = []
for i in range(n):
	if s[i] == '0':
		ans.append('0')
	elif s[i] == '1':
		ans.append('1')
	elif ans:
		ans.pop()
print(''.join(ans))


s = input()
res = ''
for c in s:
	if c == 'B':
		res = res[:-1]
	else:
		res = res + c
print(res)


S = input()
t = ''
for s in S:
	if s == 'B':
		t = t[:-1]
	else:
		t += s
print(t)


import sys
sys.setrecursionlimit(10 ** 8)
ini = lambda : int(sys.stdin.readline())
inl = lambda : [int(x) for x in sys.stdin.readline().split()]
ins = lambda : sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print('\x1b[33m', *a, '\x1b[0m', **dict(file=sys.stderr, **kw))

def solve():
	s = ins()
	x = []
	for c in s:
		if c in '01':
			x.append(c)
		elif x:
			x.pop()
	return ''.join(x)
print(solve())


ans = ''
for s in input():
	if s != 'B':
		ans += s
	elif len(ans) != 0:
		ans = ans[:-1]
print(ans)


words = input()
s = ''
for word in words:
	if word == 'B':
		s = s[:-1]
	else:
		s = s + word
print(s)


s = input()
ans = []
for ss in s:
	if ss == 'B':
		ans = ans[:-1]
	else:
		ans += ss
print(*ans, sep='')


s = input()
t = ''
for w in s:
	if w == '0':
		t += '0'
	elif w == '1':
		t += '1'
	elif len(t) > 0:
		t = t[:-1]
print(t)


import re
t = input()
while 'B' in t:
	t = t.lstrip('B')
	t = re.sub('[0,1]B', '', t)
print(t)


s = input()
r = ''
for x in s:
	if x == 'B':
		r = r[:-1]
	else:
		r = r + x
print(r)


s = str(input())
ans = ''
for i in range(len(s)):
	if s[i] != 'B':
		ans += s[i]
	elif ans != '':
		ans = ans[:-1]
print(ans)


import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce
rr = lambda : sys.stdin.readline().rstrip()
rs = lambda : sys.stdin.readline().split()
ri = lambda : int(sys.stdin.readline())
rm = lambda : list(map(int, sys.stdin.readline().split()))
rl = lambda : list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10 ** 9 + 7
s = rr()
ans = ''
for i in s:
	if i == '0':
		ans += '0'
	elif i == '1':
		ans += '1'
	elif ans:
		ans = ans[:-1]
print(ans)


a = input()
b = ''
for i in range(len(a)):
	if a[i] == 'B':
		b = b[0:len(b) - 1]
	else:
		b += a[i]
print(b)


s = str(input())
a = []
for i in range(len(s)):
	if s[i] == '0':
		a.append('0')
	elif s[i] == '1':
		a.append('1')
	elif len(a) != 0:
		a.pop()
print(''.join(a))


S = []
for c in input():
	if c == 'B':
		if S:
			S.pop()
	else:
		S.append(c)
print(*S, sep='')


x = input()
for i in range(11):
	x = x.replace('1B', '')
	x = x.replace('0B', '')
x = x.replace('B', '')
print(x)


ss = list(input())
r = ''
for (i, s) in enumerate(ss):
	if s != 'B':
		r += s
	elif len(r) > 0:
		r = r[:-1]
print(r)


def main():
	s = str(input())
	ans = []
	for val in s:
		if val == 'B' and ans == []:
			pass
		elif val == 'B' and ans != []:
			ans.pop(-1)
		else:
			ans.append(val)
	ans_str = ''
	for val in ans:
		ans_str = ans_str + val
	print(ans_str)

def __starting_point():
	main()
__starting_point()


S = input()
ans = ''
for s in S:
	if s == 'B':
		if len(ans) != 0:
			ans = ans[:-1]
	else:
		ans += s
print(ans)


s = input()
t = ''
for c in s:
	if c == 'B':
		if t != '':
			t = t[:len(t) - 1]
	else:
		t += c
print(t)


string = input()
ans = ''
for x in string:
	if x != 'B':
		ans += x
	else:
		ans = ans[:-1]
print(ans)


a = list(input())
b = []
for i in range(int(len(a))):
	t = a[int(i)]
	if t == '0':
		b.append('0')
	elif t == '1':
		b.append('1')
	elif len(b) > 0:
		del b[-1]
print(''.join(b))


s = input()
a = ''
for i in range(len(s)):
	if s[i] == '0':
		a += '0'
	elif s[i] == '1':
		a += '1'
	elif a != '':
		a = a[:-1]
print(a)


s = input()
x = []
for i in range(len(s)):
	if s[i] == '0':
		x.append('0')
	elif s[i] == '1':
		x.append('1')
	elif s[i] == 'B' and len(x) > 0:
		x.pop(-1)
print(''.join(x))


S = str(input())
stack = []
for s in S:
	if s == '0' or s == '1':
		stack.append(s)
	elif s == 'B':
		if not stack:
			continue
		else:
			stack.pop()
for s in stack:
	print(s, end='')


s = ''
for c in input():
	if c == 'B':
		s = s[0:-1]
	else:
		s += c
print(s)


import math
import collections
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(map(int, input().split()))
s = input()
ans = ''
for i in range(len(s)):
	if s[i] == 'B':
		if len(ans) == 0:
			continue
		ans = ans[0:-1]
	else:
		ans += s[i]
print(ans)


s = input()
k = ''
for i in s:
	if i != 'B':
		k += i
	else:
		k = k[:-1]
print(k)


s = input()
r = []
for i in s:
	if i == 'B':
		if r:
			del r[-1]
	else:
		r.append(i)
print(*r, sep='')


t = ''
s = input()
for i in s:
	if i == 'B' and len(t) > 0:
		t = t[:-1]
	elif i != 'B':
		t += i
print(t)


l = ['' for _ in '_' * 9]
for c in input():
	if c > '1':
		l.pop()
	else:
		l.append(c)
print(''.join(l))


s = input()
res = ''
for elem in s:
	if elem == 'B':
		res = res[:-1]
	else:
		res += elem
print(res)


s = input()
L = ''
for i in s:
	if i == 'B':
		if L:
			L = L[:-1]
	else:
		L += i
print(L)


s = input()
ans = ''
for c in s:
	if c == '0':
		ans += '0'
	elif c == '1':
		ans += '1'
	elif c == 'B' and ans:
		ans = ans[:-1]
print(ans)


s = ''
for c in input():
	if c == '0' or c == '1':
		s += c
	elif s:
		s = s[:-1]
print(s)


import sys

def solve(s: str):
	a = []
	for c in s:
		if c == 'B':
			if a:
				a.pop()
		else:
			a.append(c)
	return ''.join(a)

def main():

	def iterate_tokens():
		for line in sys.stdin:
			for word in line.split():
				yield word
	tokens = iterate_tokens()
	s = next(tokens)
	print(solve(s))

def test():
	import doctest
	doctest.testmod()

def __starting_point():
	main()
__starting_point()


s = input()
L = []
for x in s:
	if x == '0':
		L.append('0')
	elif x == '1':
		L.append('1')
	elif len(L) >= 1:
		del L[-1]
print(''.join(L))


s = ''
for i in input():
	if i != 'B':
		s += i
	elif s != '':
		s = s[:-1]
print(s)


S = input()
a = ''
for s in S:
	if s != 'B':
		a += s
	else:
		a = a[:-1]
print(a)


S = input()
ans = ''
for s in S:
	if s in '01':
		ans += s
	else:
		ans = ans[:-1]
print(ans)


s = input()
res = ''
for i in s:
	if i != 'B':
		res += i
	else:
		res = res[:len(res) - 1]
print(res)


N = str(input())
x = ''
for c in N:
	if c == 'B':
		x = x[:-1]
	else:
		x = x + c
print(x)


s = input()
l = []
for i in s:
	if i != 'B':
		l.append(i)
	elif l:
		l.pop()
print(*l, sep='')


s = str(input())
for i in range(10):
	s = s.replace('0B', '')
	s = s.replace('1B', '')
s = s.replace('B', '')
print(s)


s = input()
z = []
for i in s:
	if i == 'B':
		if z:
			z.pop()
	else:
		z.append(i)
print(''.join(z))


s = list(input())
li = []
for i in s:
	if i == '0':
		li.append('0')
	elif i == '1':
		li.append('1')
	elif i == 'B':
		if li == []:
			pass
		else:
			li.pop(-1)
print(''.join(li))


r = []
for c in input():
	if c == 'B':
		if r:
			r.pop()
	else:
		r.append(c)
print(*r, sep='')


s = input()
c = str()
for i in range(len(s)):
	if s[i] == 'B':
		c = c[:-1]
	else:
		c += s[i]
print(c)


import math
from datetime import date

def main():
	s = input()
	ans = []
	for c in s:
		if c != 'B':
			ans.append(c)
		elif len(ans) != 0:
			ans.pop()
	line = ''
	for c in ans:
		line += c
	print(line)
main()


t = []
for i in input():
	if i == 'B':
		try:
			t.pop()
		except:
			pass
	else:
		t.append(i)
print(''.join(t))


s = input()
r = ''
for i in s:
	if i != 'B':
		r += i
	if i == 'B':
		r = r[:-1]
print(r)


a = []
for c in input():
	if 'B' == c:
		a == [] or a.pop()
	else:
		a += (c,)
print(''.join(a))


S = input()
STR = ''
for i in S:
	STR = STR + i
	if i == 'B' and STR == '':
		STR = ''
	elif i == 'B':
		STR = STR[:len(STR) - 2]
print(STR)


s = input()
ans = []
for i in s:
	if i == '0':
		ans.append(0)
	elif i == '1':
		ans.append(1)
	elif len(ans) != 0:
		ans.pop(-1)
print(*ans, sep='')


n = input()
str = ''
for i in n:
	if i == '0' or i == '1':
		str = str + i
	if i == 'B':
		str = str[:-1]
print(str)


S = input()
ans = ''
for c in S:
	if c == 'B':
		ans = ans[0:-1]
	else:
		ans += c
print(ans)


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


c = list(input())
s = ''
for x in c:
	if x != 'B':
		s += x
	else:
		s = s[:-1]
print(s)


s = [ss for ss in str(input())]
ans = []
for i in s:
	if i == '0' or i == '1':
		ans.append(i)
	elif len(ans) > 0:
		ans.pop(-1)
print(''.join(ans))


s = input()
S = ''
for i in s:
	if i == 'B':
		S = S[:-1]
	else:
		S += i
print(S)


S = list(input())
ans = []
for i in range(len(S)):
	if S[i] == 'B':
		if len(ans) == 0:
			continue
		else:
			ans.pop()
	else:
		ans.append(S[i])
for i in range(len(ans)):
	print(ans[i], end='')
print()


s = input()
t = ''
for i in s:
	if i == 'B':
		t = t[:-1]
	else:
		t += i
print(t)


a = ''
for s in input():
	if s == 'B' and a != '':
		a = a[:-1]
	elif s == '0' or s == '1':
		a += s
print(a)


s = input()
ss = ''
for m in s:
	if m == 'B':
		if ss != '':
			ss = ss[:-1]
	else:
		ss += m
print(ss)


S = input()
a = ''
for s in S:
	if s == '0' or s == '1':
		a += s
	else:
		a = a[:-1]
print(a)


t = ''
for i in input():
	if i == 'B':
		if len(t) != 0:
			t = t[:-1]
	else:
		t += i
print(t)


d = ''
for s in input():
	if s == 'B':
		d = d[:-1]
	else:
		d += s
print(d)


buf = ''
str = input()
for i in range(len(str)):
	if str[i] == 'B':
		if len(buf) != 0:
			buf = buf[0:len(buf) - 1]
		else:
			continue
	else:
		buf += str[i]
print(buf)


s = input()
l = []
for i in s:
	if i == 'B':
		l = l[:-1]
	else:
		l.append(i)
print(''.join(l))


s = input()
b = ''
for i in s:
	if i == 'B':
		b = b[:-1]
	else:
		b += i
print(b)


s = input()
ans = ''
for l in s:
	if l == 'B':
		ans = ans[:-1]
	else:
		ans += l
print(ans)


import re
s = input()
for i in range(4):
	s = re.sub('[0-1]B', '', s)
print(s.replace('B', ''))


from collections import deque

def main():
	ss = list(input())
	ans = deque([])
	for s in ss:
		if s == '0':
			ans.append(s)
		elif s == '1':
			ans.append(s)
		elif len(ans) == 0:
			pass
		else:
			ans.pop()
	print(*list(ans), sep='')

def __starting_point():
	main()
__starting_point()


s = input()
text = ''
for s_i in s:
	if s_i == 'B':
		text = text[:-1]
	else:
		text += s_i
print(text)


S = input()
F = []
for ch in S:
	if ch == 'B':
		if len(F) > 0:
			F.pop()
	else:
		F.append(ch)
print(''.join(F))


n = input()
a = ''
for i in n:
	if i == '0':
		a += i
	elif i == '1':
		a += i
	elif i == 'B':
		a = a[:-1]
print(a)


s = input()
stack = []
for c in s:
	if c == 'B':
		if len(stack) == 0:
			continue
		else:
			stack.pop(-1)
	else:
		stack.extend(c)
for c in stack:
	print(c, end='')


s = input()
ans = ''
for c in s:
	if c == '0':
		ans += c
	elif c == '1':
		ans += c
	elif ans != '':
		ans = ans[:-1]
print(ans)


s = input()
st = []
for e in s:
	if e == 'B':
		if len(st) != 0:
			st.pop()
	else:
		st.append(int(e))
print(''.join(map(str, st)))


S = input()
out = ''
for c in S:
	if c == '0' or c == '1':
		out += c
	else:
		out = out[:-1]
print(out)


from collections import deque
S = input()
ans = deque([])
for s in S:
	if s == 'B':
		if ans:
			ans.pop()
	else:
		ans.append(s)
print(''.join(ans))


a = list(input())
ans = []
for i in range(len(a)):
	if a[i] == '0':
		ans.append('0')
	elif a[i] == '1':
		ans.append('1')
	elif a[i] == 'B':
		if ans == []:
			continue
		else:
			ans.pop(-1)
print(''.join(ans))


import os
import sys

def main():
	S = input()
	stack = []
	for s in S:
		if s == '0' or s == '1':
			stack.append(s)
		elif s == 'B' and stack:
			stack.pop()
	for sta in stack:
		print(sta, end='')
	print()

def __starting_point():
	main()
__starting_point()


s = input()
ss = ''
for c in s:
	if c == 'B':
		ss = ss[:-1]
	else:
		ss += c
print(ss)


s = input()
a = ''
for i in s:
	if i == '1' or i == '0':
		a += i
	elif a:
		a = a[:-1]
print(a)


s = input()
for _ in [0] * 4:
	s = s.replace('1B', '')
	s = s.replace('0B', '')
print(s.strip('B'))


s = []
for i in input():
	if i == 'B':
		s = s[:-1]
	else:
		s += i
print(''.join(s))


s = input()
out = ''
for x in s:
	if x != 'B':
		out += x
	elif out == '':
		continue
	else:
		out = out[:-1]
print(out)


s = list(input())
t = ''
for s_ in s:
	if s_ != 'B':
		t += s_
	else:
		t = t[:-1]
print(t)


def handle_string(string):
	new_string = ''
	for i in range(len(string)):
		if string[i] == 'B':
			if len(new_string) != 0:
				new_string = new_string[0:len(new_string) - 1]
			else:
				continue
		else:
			new_string = new_string + string[i]
	return new_string
input_string = input()
print(handle_string(input_string))


s = list(input())
x = len(s)
a = []
for i in range(x):
	if s[i] == '0':
		a.append('0')
	elif s[i] == '1':
		a.append('1')
	elif s[i] == 'B':
		if a == []:
			continue
		else:
			a.pop(-1)
b = ''.join(a)
print(b)


S = input()
word = ''
for s in S:
	if s == 'B':
		word = word[:-1]
	else:
		word += s
print(word)


S = input()
ans = ''
for s in S:
	if s == '0':
		ans += '0'
	elif s == '1':
		ans += '1'
	elif len(ans) > 0:
		ans = ans[:-1]
print(ans)