#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
char a[N];
int get_maxi(int v) {
  char max = 'a';
  int len = strlen(a);
  for (int i = v; i < len; ++i) {
    if (a[i] >= max) {
      max = a[i];
      v = i;
    } else
      continue;
  }
  return v;
}
int main() {
  scanf("%s", a);
  int v = 0;
  int len = strlen(a);
  int x = v;
  int flag = 0;
  v = get_maxi(v);
  while (1) {
    x == 0 ? 0 : x + 1;
    for (int i = x; i <= v; ++i) {
      if (a[i] == a[v]) {
        cout << a[i];
      }
      if (i == len - 1) {
        flag = 1;
      }
    }
    if (flag == 1) break;
    x = v;
    v = get_maxi(v + 1);
  }
  cout << endl;
  return 0;
}
