#include <iostream>
#include <cmath>
using namespace std;
char c[232],top; 
int main() {
	char ch;
	while(cin>>ch) {
		if(ch=='B'&&top)top--;
		if(ch!='B')c[top++]=ch;
	}
	for(int i=0;i<top;++i) cout<<c[i]; cout<<endl;
	return 0;
}