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 <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int N;
const int MAX_N = 200010;

char a[MAX_N],b[MAX_N];
int dp[MAX_N],path[MAX_N];

int pos[26][MAX_N];

int main(){
	
	scanf("%s",a);
	N=strlen(a);

	for(int i=0;i<26;i++)pos[i][N]=N+1;
	for(int i=N-1;i>=0;i--){
		for(int j=0;j<26;j++){
			pos[j][i]=pos[j][i+1];
		}
		pos[a[i]-'a'][i]=i;
	}
	dp[N]=1;

	for(int i=N-1;i>=0;i--){
		dp[i]=1e9;
		for(int j=0;j<26;j++){
			if(dp[i]>dp[pos[j][i]+1]+1){
				dp[i]=dp[pos[j][i]+1]+1;
				path[i]=pos[j][i]+1;
				b[i]=j+'a';
			}
		}
	}

	for(int i=0;i<N;i=path[i]){
		putchar(b[i]);
	}
	puts("");

	return 0;
}