#include <bits/stdc++.h>
using namespace std;
int main() {
  string input;
  cin >> input;
  map<char, int> appearanceTimes;
  for (int i = 0; i < input.size(); i++) appearanceTimes[input[i]]++;
  set<char> sorted;
  char toPrint;
  for (auto p : appearanceTimes) {
    sorted.insert(p.first);
    toPrint = p.first;
  }
  for (int i = 0; i < input.size(); i++) {
    if (appearanceTimes[toPrint] == 0) {
      set<char>::iterator pointer;
      pointer = sorted.find(toPrint);
      pointer--;
      toPrint = *pointer;
    }
    if (input[i] == toPrint) cout << toPrint;
    appearanceTimes[input[i]]--;
    if (appearanceTimes[input[i]] == 0) sorted.erase(input[i]);
  }
  return 0;
}
