#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  stack<char> index = stack<char>();
  for (int i = (0); i < (s.size()); i++) {
    char ch = s[i];
    if (index.empty() || ch <= index.top()) {
      index.push(ch);
      continue;
    } else {
      while (!index.empty() && ch > index.top()) index.pop();
      index.push(ch);
    }
  }
  vector<char> res = vector<char>();
  while (!index.empty()) {
    res.push_back(index.top());
    index.pop();
  }
  for (int i = res.size() - 1; i >= 0; i--) cout << res[i];
  return 0;
}
