#include <bits/stdc++.h>
using namespace std;
const int N = 100;
const long long mod = 1e9 + 7;
vector<int> e[N];
int vis[N];
void dfs(int i, int p, int count) {}
bool comp(pair<long long, long long>& a, pair<long long, long long>& b) {
  return a.first > b.first && a.second < b.second;
}
long long binpow(long long a, long long b) {
  if (b == 0) return 1;
  if (a == 0) return 0;
  if (b == 1) return a % mod;
  long long g = (binpow(a, b / 2) % mod) * (binpow(a, b / 2) % mod);
  g %= mod;
  if (b & 1)
    return a * g;
  else
    return g;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  while (T--) {
    string s;
    cin >> s;
    map<char, int> m, p;
    vector<char> v;
    for (int i = 0; i < s.size(); i++) {
      if (m[s[i]] == 0) {
        v.push_back(s[i]);
        m[s[i]] = i + 1;
      }
      p[s[i]] = i + 1;
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    string t = "";
    for (int i = m[v[0]] - 1; i < p[v[0]]; i++) {
      if (s[i] == v[0]) t += v[0];
    }
    int k = p[v[0]];
    for (int i = 1; i < v.size(); i++) {
      if (p[v[i]] > k) {
        for (int j = k; j < p[v[i]]; j++)
          if (s[j] == v[i]) t += v[i];
        k = p[v[i]];
      }
    }
    cout << t << endl;
  }
}
