#include <bits/stdc++.h>
using namespace std;
long long int n, k, l, m, t, a, b, s, r, c, temp1, temp2, x, y, temp, q, d,
    mod = 1e9 + 7, w;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  deque<char> dq;
  for (int i = 0; i < s.length(); i++) {
    while (!dq.empty() && s[i] > dq.front()) {
      dq.pop_front();
    }
    dq.push_front(s[i]);
  }
  string ans = "";
  for (auto x : dq) ans += x;
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}
