#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  return os << "]";
}
template <typename T>
void __printer(const char* var_name, T&& val) {
  cerr << var_name << " = " << val << endl;
}
template <typename T, typename... Arguments>
void __printer(const char* arg_names, T&& val, Arguments&&... remaining_args) {
  const char* comma = strchr(arg_names + 1, ',');
  cerr.write(arg_names, comma - arg_names) << " = " << val << ", ";
  __printer(comma + 1, remaining_args...);
}
template <typename T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long int _ = 1;
  while (_--) {
    string s;
    cin >> s;
    long long int n = s.size();
    std::vector<char> v(n + 1);
    long long int g = s[n - 1];
    for (long long int i = n - 1; i >= 0; --i) {
      v[i + 1] = g;
      if (g < s[i]) g = s[i];
    }
    v[0] = g;
    long long int i = 0;
    string r = "";
    s = "Z" + s;
    while (i < n) {
      while (i < n and v[i] != s[i + 1]) i++;
      if (i <= n) r += v[i];
      i++;
    }
    cout << r << '\n';
  }
  return 0;
}
