#include <bits/stdc++.h>
using namespace std;
const int N = 111111;
const int INF = int(1e9), mod = INF + 7;
pair<char, int> mx[N];
int main() {
  char s[N];
  gets(s);
  int n = strlen(s);
  mx[n - 1] = make_pair(s[n - 1], n - 1);
  for (int i = n - 2; i >= 0; --i) {
    mx[i] = mx[i + 1];
    if (s[i] > mx[i + 1].first) {
      mx[i] = make_pair(s[i], i);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int it = i; it <= mx[i].second; ++it)
      if (mx[i].first == s[it]) putchar(s[it]);
    i = mx[i].second;
  }
  return 0;
}
