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 (GCC 5.4.1) (judge verdict: Wrong Answer)


//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

/*
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
*/

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define swap(p,q) r=(p);(p)=(q);(q)=r
#define INF 1000000000000//10^12
#define INFINT 2000000001//2*10^9+1

//using namespace std;

int main(void)
{
	//変数の宣言
	static char a[200010];
	static int b[30];
	static int binv[30];
	static int c[30][30];
	static int d[30][30][30];
	static int e[30][30][30][30];


	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	double temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;



	//データの読み込み


	scanf("%s",&a);
//	scanf_s("%s",&a,200010);

//	for(i=1;i<=n;i++){
//		scanf("%lld %lld %d",&x[i],&y[i],&r[i]);
//		scanf_s("%lld %lld %d",&x[i],&y[i],&r[i]);
//	}
	
	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理


	for(i=0;i<30;i++){
		b[i]=-1;
		binv[i]=-1;
		for(j=0;j<30;j++){
			c[i][j]=-1;
			for(k=0;k<30;k++){
				d[i][j][k]=-1;
				for(l=0;l<30;l++){
					e[i][j][k][l]=-1;
				}
			}
		}
	}

	len=strlen(a);


	for(i=0;i<len;i++){
		if(b[a[i]-97]==-1){
			b[a[i]-97]=i;
		}
	}
	
	for(i=1;i<len;i++){
		for(j=0;j<26;j++){
			if(b[j]<i&&c[j][a[i]-97]==-1){
				c[j][a[i]-97]=i;
			}
		}
	}

	for(i=2;i<len;i++){
		for(j=0;j<26;j++){
			for(k=0;k<26;k++){
				if(c[j][k]<i&&d[j][k][a[i]-97]==-1){
					d[j][k][a[i]-97]=i;
				}
			}
		}
	}

	for(i=len-1;i>=0;i--){
		if(binv[a[i]-97]==-1){
			binv[a[i]-97]=i;
		}
	}

	for(i=0;i<26;i++){
		for(j=0;j<26;j++){
			for(k=0;k<26;k++){
				for(l=0;l<26;l++){
					if((d[i][j][k]!=-1&&binv[l]!=-1)&&d[i][j][k]>binv[l]){
						e[i][j][k][l]=1;
					}
				}
			}
		}
	}

	for(i=0;i<26;i++){
		if(b[i]==-1){
			printf("%c",i+97);
			return 0;
		}
	}


	for(i=0;i<26;i++){
		for(j=0;j<26;j++){
			if(c[i][j]==-1){
				printf("%c%c",i+97,j+97);
				return 0;
			}
		}
	}


	for(i=0;i<26;i++){
		for(j=0;j<26;j++){
			for(k=0;k<26;k++){
				if(d[i][j][k]==-1){
					printf("%c%c%c",i+97,j+97,k+97);
					return 0;
				}
			}
		}
	}

	for(i=0;i<26;i++){
		for(j=0;j<26;j++){
			for(k=0;k<26;k++){
				for(l=0;l<26;l++){
					if(e[i][j][k][l]==-1){
						printf("%c%c%c%c",i+97,j+97,k+97,l+97);
						return 0;
					}
				}
			}
		}
	}

	//	printf("計算部分終了\n");

	//出力

	//printf("%d",'a');

	//	printf("結果の出力終了\n");


	return 0;
}