#include <bits/stdc++.h>
using namespace std;
int ara[1000000];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int i, j, k, n, x, a, b, c, high = 0, flag = 0, d;
  string s, s2;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    d = s[i] - 'a';
    high = max(d, high);
  }
  n = s.size();
  for (i = n - 1; i >= 0; i--) {
    if (s[i] - 'a' == high) flag = 1;
    if (flag) {
      if (s[i] - 'a' < high) s.erase(s.begin() + i);
    }
  }
  s2 = s;
  high = 0;
  for (i = s2.size() - 1; i >= 0; i--) {
    d = s2[i] - 'a';
    high = max(d, high);
    ara[i] = high;
  }
  vector<int> era;
  for (int i = 0; i < s2.size() - 1; i++) {
    c = s2[i] - 'a';
    if (c < ara[i]) {
      era.push_back(i);
    }
  }
  j = 0;
  for (int i = 0; i < era.size(); i++) {
    s2.erase(s2.begin() + era[i] - j);
    j++;
  }
  cout << s2;
}
