#include <bits/stdc++.h>
using namespace std;
int i, j, n, m, k, b[200000];
string s;
char c;
int main() {
  cin >> s;
  n = s.size();
  c = s[n - 1];
  for (i = 0; i <= n; i++) b[i] = n + 1;
  k = 0;
  j = n + 1;
  for (i = n - 1; i >= 0; i--) {
    if (c <= s[i]) b[i] = j;
    c = max(c, s[i]);
    if (s[i] == c) {
      k = i;
      j = i;
    }
  }
  while (k < n) {
    cout << s[k];
    k = b[k];
  }
  return 0;
}
