#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using dl = double;
using ull = unsigned long long;
const long N = 3e5 + 10;
ll aarray[N];
ll magic[510][510];
vector<ll> primes;
bool check[1000001];
ll vis[N];
map<char, ll> mp;
char ch[100000 + 10];
void solve() {
  ll i, j, n, m, k, l, sum = 0, ans;
  string str, s = "";
  bool yes = true;
  cin >> str;
  ll cnt[30] = {0};
  char cc = str[str.length() - 1];
  ch[str.length() - 1] = cc;
  for (i = 0; i < str.length(); i++) {
    mp[str[i]] = i;
  }
  if (str.length() > 1) {
    for (i = str.length() - 2; i >= 0; i--) {
      ch[i] = max(str[i], ch[i + 1]);
    }
  }
  ll len = str.length();
  char cur = ch[0];
  i = 0;
  while (i < len) {
    if (str[i] == cur) {
      s += str[i];
    }
    if (i == mp[cur]) {
      cur = ch[i + 1];
    }
    i++;
  }
  cout << s << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string str;
  ll i, j, n, m, k, t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
