#include <bits/stdc++.h>
using namespace std;
char s[1000010];
char sck[1000010];
int main() {
  scanf("%s", s);
  int i;
  int top = 0;
  int len = strlen(s);
  for (i = 0; i < len; i++) {
    while (top && s[i] > sck[top - 1]) top--;
    sck[top++] = s[i];
  }
  for (i = 0; i < top; i++) printf("%c", sck[i]);
  puts("");
  return 0;
}
