Problem:
Score : 600 points

Problem Statement

A subsequence of a string S is a string that can be obtained by deleting zero or more characters from S without changing the order of the remaining characters.
For example, arc, artistic and (an empty string) are all subsequences of artistic; abc and ci are not.

You are given a string A consisting of lowercase English letters.
Find the shortest string among the strings consisting of lowercase English letters that are not subsequences of A.
If there are more than one such string, find the lexicographically smallest one among them.

Constraints

1 \leq |A| \leq 2 \times 10^5

A consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

A

Output

Print the lexicographically smallest string among the shortest strings consisting of lowercase English letters that are not subsequences of A.

Sample Input 1

atcoderregularcontest

Sample Output 1

b

The string atcoderregularcontest contains a as a subsequence, but not b.

Sample Input 2

abcdefghijklmnopqrstuvwxyz

Sample Output 2

aa

Sample Input 3

frqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhyktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnfgmnjcvtlpnclfkpervxmdbvrbrdn

Sample Output 3

aca

Solution in C++14 (GCC 5.4.1) (judge verdict: Time Limit Exceeded)

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
vector<int> dt[26];
bool good(string s){
  int cur = -1;
  for(int i = 0;i < s.size();i++){
    auto it = upper_bound(dt[s[i] - 'a'].begin(), dt[s[i] - 'a'].end(), cur);
    if(it == dt[s[i] - 'a'].end())
      return false;
    cur = *it;
  }
  return true;
}
string s;
bool bt(int rem){
  if(rem == 0)
    return !good(s);
  for(int i = 0;i < 26;i++){
    s += char('a' + i);
    if(bt(rem - 1))
      return true;
    s.pop_back();
  }
  return false;
}
signed main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  string ss;
  cin >> ss;
  for(int i = 0;i < ss.size();i++)
    dt[ss[i] - 'a'].push_back(i);
//  cout << 123 << endl;

  for(int i = 1;;i++){
    if(bt(i)){
      cout << s;
      return 0;
    }
  }
}