#include <bits/stdc++.h>
using namespace std;
int main() {
  string input, max_chars, result;
  cin >> input;
  result = "";
  max_chars = input;
  char r = input[input.size() - 1];
  for (int i = input.size() - 2; i >= 0; i--) {
    if (input[i] > r) r = input[i];
    max_chars[i] = r;
  }
  for (int i = 0; i < input.size() - 1; i++) {
    if (input[i] >= max_chars[i + 1]) result += input[i];
  }
  result += input[input.size() - 1];
  cout << result << endl;
  return 0;
}
