#include <bits/stdc++.h>
using namespace std;
class pair_comparison {
 public:
  bool operator()(const pair<char, int>& lhs,
                  const pair<char, int>& rhs) const {
    if (lhs.first == rhs.first) {
      return lhs.second > rhs.second;
    }
    return lhs.first < rhs.first;
  }
};
int main() {
  string s;
  cin >> s;
  vector<pair<char, int> > s_vec(s.size());
  for (int i = 0; i < s.size(); i++) {
    s_vec[i] = make_pair(s[i], i);
  }
  priority_queue<pair<char, int>, vector<pair<char, int> >, pair_comparison>
      pqueue(pair_comparison(), s_vec);
  string res(s.size(), ' ');
  int curr_pos = -1;
  int curr_idx = 0;
  while (!pqueue.empty()) {
    pair<char, int> top_elem = pqueue.top();
    pqueue.pop();
    if (top_elem.second > curr_pos) {
      res[curr_idx++] = top_elem.first;
      curr_pos = top_elem.second;
    }
  }
  cout << res << "\n";
  return 0;
}
