#include <bits/stdc++.h>
using namespace std;
const int dir[9][2] = {0, 1, 0,  -1, 1, 0,  -1, 0, 1,
                       1, 1, -1, -1, 1, -1, -1, 0, 0};
const int inf = 0x3f3f3f;
const long long ll_inf = (long long)1e15;
const double pi = acos(-1.0);
const int mod = (long long)1e9 + 7;
const int Max = (int)1e5 + 51;
const long double eps = 1e-10;
char arr[Max];
char ans[Max];
int main() {
  while (~scanf("%s", arr)) {
    memset(ans, 0, sizeof(ans));
    int len = strlen(arr);
    int maxc = -1;
    int pos = 0;
    for (int i = len - 1; i >= 0; --i) {
      if (arr[i] - '0' >= maxc) {
        maxc = arr[i] - '0';
        ans[pos++] = arr[i];
      }
    }
    for (int i = pos - 1; i >= 0; --i) {
      printf("%c", ans[i]);
    }
    printf("\n");
  }
  return 0;
}
