#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
long long n, ans, a, b, c;
int ch;
pair<int, int> par;
vector<char> used;
string second, t;
bool cmpvp(pair<float, int> p1, pair<float, int> p2) {
  if (p1.first > p2.first) return 1;
  if (p1.first == p2.first)
    if (p1.second < p2.second) return 1;
  return 0;
}
int main() {
  cin >> second;
  ch = 0;
  vector<int> v(26, 0);
  for (int i = 0; second[i]; ++i)
    v[second[i] - 'a'] = i, ch = max(ch, second[i] - 'a');
  for (int i = 0; second[i]; ++i) {
    if (ch == second[i] - 'a') {
      cout << second[i];
      if (v[ch] == i) {
        --ch;
        while (!v[ch] || v[ch] < i) --ch;
      }
    }
  }
  return 0;
}
