#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[100005], ans[100005] = {'\0'};
  cin >> s;
  int l = strlen(s), i, j = 0;
  ans[0] = '\0';
  for (i = 0; i < l; i++) {
    int k = 1;
    while ((j - k) >= 0 && s[i] > ans[j - k]) {
      ans[j - k] = '\0';
      k++;
    }
    ans[j - k + 1] = s[i];
    j = j - k + 2;
  }
  cout << ans << endl;
}
