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: Accepted)

#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;

int Path[26][200010];
int From[200010];
string A;
void dp(){
    for(int i = 0; i < 200010; i++)From[i] = -1;
    A = "#" + A;
    int L = A.size();
    for(int i = 0; i < 26; i++){
        Path[i][L-1] = 200005;
        for(int j = L-1; j > 0; j--){
            if(A[j] - 'a' == i)Path[i][j-1] = j;
            else Path[i][j-1] = Path[i][j];
        }
    }
}
int main(){
    cin >> A;
    dp();
    queue<int>Q;
    Q.push(0);
    while(true){
        int pos = Q.front();
        Q.pop();
        if(pos == 200005)break;
        for(int i = 0; i < 26; i++){
            if(From[Path[i][pos]] != -1)continue;
            From[Path[i][pos]] = pos;
            Q.push(Path[i][pos]);
        }
    }
    string ans = "";
    for(int pos = 200005; pos; pos = From[pos]){
        for(int i = 0; i < 26; i++){
            if(Path[i][From[pos]] == pos){
                ans += string(1, 'a'+i);
                break;
            }
        }
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;
    return 0;
}