#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.length();
  int idx = 0;
lable:
  char ch;
  int idx1 = 0;
  bool flag = false;
  for (int j = idx; j < n; j++) {
    if (j == idx) {
      ch = s[j];
    } else {
      ch = max(ch, s[j]);
    }
  }
  for (int j = idx; j < n; j++) {
    if (s[j] == ch) {
      cout << ch;
      flag = true;
      idx1 = max(idx1, j);
    }
  }
  if (flag == true) {
    idx = idx1 + 1;
    goto lable;
  }
  return 0;
}
