#include <bits/stdc++.h>
using namespace std;
string s, ans;
void dfs(int b, string cur) {
  for (int i = b + 1; i < ((int)s.size()); i++)
    if (s[b] >= s[i]) {
      cur.push_back(s[i]);
      dfs(i, cur);
      cur.erase(cur.begin() + ((int)cur.size()) - 1);
    }
  ans = max(ans, cur);
}
int main() {
  cin >> s;
  char mx = 0;
  int b = 0;
  for (int i = 0; i < ((int)s.size()); i++)
    if (s[i] > mx) {
      b = i;
      mx = s[i];
    }
  ans.push_back(s[b]);
  int MAX = mx;
  for (int i = b; i < ((int)s.size()); i++) {
    mx = 0;
    int cur = 0;
    for (int j = i + 1; j < ((int)s.size()); j++)
      if (s[j] > mx) {
        cur = j;
        mx = s[j];
        if (mx == MAX) break;
      }
    MAX = mx;
    if (cur > i) {
      ans.push_back(mx);
      i = max(i, cur - 1);
    }
  }
  cout << ans << endl;
  return 0;
}
