#include <bits/stdc++.h>
using namespace std;
const int INF_MAX = 0x7FFFFFFF;
const int INF_MIN = -(1 << 31);
const double eps = 1e-10;
const double pi = acos(-1.0);
template <class T>
inline T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
int dir_4[4][2] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}};
int dir_8[8][2] = {{0, 1},  {-1, 1}, {-1, 0}, {-1, -1},
                   {0, -1}, {1, -1}, {1, 0},  {1, 1}};
stack<char> s;
stack<char> a;
void fun(char k) {
  while (!s.empty() && k > s.top()) s.pop();
  s.push(k);
}
void output() {
  while (!s.empty()) {
    a.push(s.top());
    s.pop();
  }
  while (!a.empty()) {
    cout << a.top();
    a.pop();
  }
  cout << endl;
  return;
}
int main() {
  string ss;
  cin >> ss;
  for (int i = 0; i < ss.length(); i++) {
    fun(ss[i]);
  }
  output();
}
