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)

#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#define N 200005
using namespace std;
int da,i,j,k,l,r,d,n,m,ans[N],last[N][27],f[27];
char c[N];
struct node {
	int x,y,last;
}q[N*70];
inline void print(int x,int y) {
	ans[++da]=y;
	while (x) ans[++da]=q[x].x,x=q[x].last;
	for (int i=da;i;i--) printf("%c",char(96+ans[i]));
}
int main() {
	scanf("%s",c+1);
	l=strlen(c+1);
	int L=l;
	for (i=1;i<=26;i++) last[l][i]=l+1,f[i]=l+1;
	f[c[l]-96]=l;
	for (i=l-1;i;i--) {
		f[c[i]-96]=i;
		for (j=1;j<=26;j++) last[i][j]=last[i+1][j];
		last[i][c[i+1]-96]=i+1;
	}
	int l=0,r=26;
	for (i=1;i<=26;i++) {
		if (f[i]>L) {
			printf("%c",char(96+i)); return 0;
		}
		q[i].x=i,q[i].y=f[i],q[i].last=0;
	}
	while (l<=r) {
		++l;
		for (int i=1;i<=26;i++) if (last[q[l].y][i]>L) {	
			print(l,i); return 0;
		}
		else q[++r].x=i,q[r].last=l,q[r].y=last[q[l].y][i];
	}
}