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# (Mono 4.6.2.0) (judge verdict: Time Limit Exceeded)

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int N = S.Length;
		int[][] last = new int[N+1][];
		for(int i=0;i<N;i++){
			last[i] = new int[26];
			for(int j=0;j<26;j++){
				last[i][j] = -1;
			}
		}
		for(int i=N-1;i>=0;i--){
			if(i+1<N) for(int j=0;j<26;j++) last[i][j] = last[i+1][j];
			last[i][S[i] - 'a'] = i;
		}
		
		int[] cnt = new int[26];
		for(int i=0;i<N;i++) cnt[S[i] - 'a']++;
		for(int i=0;i<26;i++){
			if(cnt[i] == 0){
				Console.WriteLine((char)('a' + i));
				return;
			}
		}
		
		
		var Q = new Queue<Pair>();
		for(int j=0;j<26;j++){
			var p = new Pair();
			p.Depth = 0;
			p.C[p.Depth] = (char)('a' + j);
			p.Now = last[0][j];
			Q.Enqueue(p);
		}
		
		while(Q.Count>0){
			var p = Q.Dequeue();
			if(p.Now == N-1){
				Console.WriteLine(new String(p.C) + "a");
				return;
			}
			for(int j=0;j<26;j++){
				if(last[p.Now+1][j] == -1){
					var ca = new char[p.Depth+2];
					for(int k=0;k<=p.Depth;k++) ca[k] = p.C[k];
					ca[p.Depth+1] = (char)('a' + j);
					Console.WriteLine(new String(ca));
					return;
				}
				var np = new Pair(p);
				np.Depth++;
				np.C[np.Depth] = (char)('a' + j);
				np.Now = last[p.Now + 1][j];
				Q.Enqueue(np);
			}
		}
		
		
	}
	
	class Pair{
		public char[] C;
		public int Depth;
		public int Now;
		public Pair(){
			C = new char[5];
		}
		public Pair(Pair p){
			C = (char[]) p.C.Clone();
			Depth = p.Depth;
			Now = p.Now;
		}
	}
	
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}