#include <bits/stdc++.h>
using namespace std;
const long long MaxN = 1E5 + 10;
const long long INF = 1E9 + 7;
const long long MOD = 1000 * 1000 * 1000 + 7;
vector<pair<char, long long> > v;
bool cmp(pair<char, long long> a, pair<char, long long> b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first > b.first;
}
int32_t main() {
  string second;
  cin >> second;
  for (long long i = 0; i < second.size(); ++i)
    v.push_back(pair<char, long long>(second[i], i + 1));
  sort(v.begin(), v.end(), cmp);
  long long last_ind = 0;
  for (long long i = 0; i < v.size(); ++i)
    if (v[i].second > last_ind) {
      cout << v[i].first;
      last_ind = v[i].second;
    }
}
