#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int INF = 0x3fffffff;
const double EPS = 1e-8;
const double PI = 2 * asin(1);
string s;
void pretreat() { ; }
bool input() {
  cin >> s;
  if (cin.eof()) return false;
  return true;
}
void solve() {
  string s_ans;
  map<char, int> mci;
  for (auto &c : s) ++mci[c];
  for (auto &c : s) {
    auto mcit_e = mci.end();
    --mcit_e;
    if (c == mcit_e->first) s_ans.push_back(c);
    --mci[c];
    if (mci[c] == 0) mci.erase(c);
  }
  cout << s_ans << endl;
}
int main() {
  pretreat();
  while (input()) {
    solve();
  }
  return 0;
}
