#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  while (cin >> s) {
    int i = 0, n = s.size();
    char c = s[0];
    for (int j = 0; j < n; j++)
      if (c < s[j]) c = s[j], i = j;
    string ans;
    c = s[n - 1];
    for (int j = n - 1; j >= i; j--) {
      if (c <= s[j]) {
        c = s[j];
        ans.push_back(c);
      }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
  }
  return 0;
}
