#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int maxn = 2e5 + 5;
const double pi = acos(-1);
const double EPS = 1e-6;
const int mod = 1e9 + 7;
const int N = 1e3 + 5;
int dr[4] = {1, -1, 0, 0};
int dc[4] = {0, 0, 1, -1};
void myMain() {
  string s;
  cin >> s;
  string alpha = s;
  sort(alpha.begin(), alpha.end());
  string ans = "";
  for (int i = 0; i < (int)(s.size()) - 1; i++) {
    if (s[i] == alpha.back())
      ans += s[i], alpha.pop_back();
    else {
      char x = s[i];
      alpha.erase(alpha.find(x), 1);
    }
  }
  ans += s.back();
  cout << ans << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  int t = 1;
  while (t--) {
    myMain();
  }
}
