#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, tail;
char s[N], a[N];
int main() {
  scanf("%s", s);
  n = strlen(s);
  tail = 1;
  a[1] = s[0];
  for (int i = 1; i < n; i++)
    if (s[i] <= a[tail])
      a[++tail] = s[i];
    else {
      while (tail && s[i] > a[tail]) --tail;
      a[++tail] = s[i];
    }
  for (int i = 1; i <= tail; i++) printf("%c", a[i]);
  printf("\n");
  return 0;
}
