#include <iostream>
#include <vector>
using namespace std;

int main(){
  string S;
  cin >> S;
  vector<char> v;
  for(int i=0;i<S.size();i++){
    if(S[i]!='B') v.push_back(S[i]);
    else if(!v.empty()) v.pop_back();
  }
  for(auto c:v) cout << c;
  cout << endl;
}