#include <bits/stdc++.h>
using namespace std;
char s[100005];
int n;
int d[100005];
int rem[30];
int main() {
  scanf("%s", s);
  n = strlen(s);
  memset(rem, -1, sizeof(rem));
  char bg = 'a' - 1;
  int f = 0;
  for (int i = 0; i < n; ++i) {
    rem[s[i] - 'a'] = i;
    if (bg < s[i]) {
      bg = s[i], f = i;
    }
  }
  while (f < n) {
    printf("%c", s[f]);
    for (int i = n - 1; i > f; --i) {
      if (s[i] == s[f]) {
        for (int j = f + 1; j <= i; ++j)
          if (s[j] == s[f]) printf("%c", s[j]);
        f = i;
        break;
      }
    }
    for (int i = s[f] - 'a'; i >= 0; --i) {
      if (rem[i] > f) {
        bg = 'a' + i;
        break;
      }
    }
    if (bg != s[f]) {
      for (; f < n; ++f)
        if (s[f] == bg) break;
    } else
      break;
  }
  return 0;
}
