#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  deque<char> answer;
  string input;
  cin >> input;
  for (int i = 0; i < input.size(); i++) {
    while (!answer.empty() && input[i] > answer.back()) answer.pop_back();
    answer.push_back(input[i]);
  }
  while (!answer.empty()) cout << answer.front(), answer.pop_front();
  cout << endl;
  return 0;
}
