#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  cin >> s;

  string ans = "";
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != 'B') ans += s[i];
    else if (ans != "") ans.pop_back();
  }

  cout << ans << endl;
}