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: Wrong Answer)

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <string>//"reverse(s's it,s's it)"
//#include <algorithm>//"lower_bound(it,it,v)" "next_permutation(a,a+n)"
//"reverse(v's it,v's it)"(v: vector)
using namespace std;
void chmin(int &a,int b){	a=min(a,b);	return;	}

#define INF 200001
#define MAX_C 7700//Mind here.

int fin[26][MAX_C],c[26][INF];

int main(){
	string s;
	cin>>s;
	reverse(s.begin(),s.end());
	for(int j=0;j<26;++j){
		fill(fin[j],fin[j]+MAX_C,INF);
		fin[j][0]=-1;
	}
	for(int i=0;i<s.size();++i){
		int j0=s[i]-'a',l=INF;
		for(int j=0;j<26;++j) chmin(l,lower_bound(fin[j],fin[j]+MAX_C,i)-fin[j]);
		chmin(fin[j0][l],i);
		if(i==0){
			for(int j=0;j<26;++j){
				if(j==j0) c[j][0]=1;
				else c[j][0]=0;
			}
		}else{
			for(int j=0;j<26;++j){
				if(j==j0) c[j][i]=c[j][i-1]+1;
				else c[j][i]=c[j][i-1];
			}
		}
	}
	int l=1+INF,x=0;
	for(int j=0;j<26;++j){
		int nl=lower_bound(fin[j],fin[j]+MAX_C,INF)-fin[j];
		if(l>nl){
			x=j;
			l=nl;
		}
	}
	string ans(l,'a');
	ans[l-1]='a'+x;
	if(l==1){
		cout<<ans<<endl;
		return 0;
	}
	for(int i=l-1;i>0;--i){
		x=ans[i]-'a';
		int k=lower_bound(c[x]+fin[x][i],c[x]+fin[x][i+1],c[x][fin[x][i+1]-1])-c[x];
		for(int j=0;j<26;++j) if(k<fin[j][i]&&fin[j][i]<=fin[x][i+1]){
			ans[i-1]='a'+j;
			break;
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
}