#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  vector<vector<int>> pos(26);
  for (int i = 0; i < s.size(); i++) pos[s[i] - 'a'].push_back(i);
  for (int i = 0; i < 26; i++) reverse(pos[i].begin(), pos[i].end());
  int ls = -1;
  string ans;
  for (int i = 25; i >= 0; i--) {
    while (!pos[i].empty() && pos[i].back() < ls) pos[i].pop_back();
    while (!pos[i].empty())
      ans += i + 'a', ls = pos[i].back(), pos[i].pop_back();
  }
  cout << ans << '\n';
  return 0;
}
