#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, i, j, k, l, m, b, t, sum, sum1, flag, max1, min1, tmp;
  string s;
  cin >> s;
  char c = 'a';
  map<char, long long> mp;
  for (i = 0; i < s.size(); i++) {
    if (s[i] > c) {
      c = s[i];
    }
    mp[s[i]]++;
  }
  vector<char> v;
  for (i = 0; i < s.size(); i++) {
    if (s[i] == c) {
      if (mp[c] > 0) {
        while (mp[c] > 0) {
          if (s[i] == c) {
            cout << c;
            mp[c]--;
          } else {
            mp[s[i]]--;
          }
          i++;
        }
        c--;
        i--;
        while (mp[c] == 0 and c >= 'b') {
          c--;
        }
      }
    } else {
      mp[s[i]]--;
    }
  }
}
