#include <bits/stdc++.h>
using namespace std;
const int N = 100500;
map<char, vector<int> > a;
int l[N];
int main() {
  srand(time(NULL));
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    a[s[i]].push_back(i);
  }
  int pos = -1;
  for (char i = 'a'; i <= 'z'; i++) {
    l[i] = 0;
  }
  string ans = "";
  int n = int(s.size());
  bool w = true;
  while (w) {
    w = false;
    for (char j = 'z'; j >= 'a'; j--) {
      while (l[j] < a[j].size() && a[j][l[j]] < pos) {
        l[j]++;
      }
      if (l[j] < a[j].size() && pos < a[j][l[j]]) {
        w = true;
        ans += j;
        pos = a[j][l[j]];
        l[j]++;
        break;
      }
    }
  }
  cout << ans;
  return 0;
}
