#include <bits/stdc++.h>
std::vector<char> a;
int main(void)
{
	std::string s;
	std::cin >> s;
	for (auto c : s)
		if (c == 'B' && a.size())
			a.pop_back();
		else if (c ^ 'B')
			a.push_back(c);
	for (auto c : a)
		std::cout << c;
	return 0;
}