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: Time Limit Exceeded)

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define sec second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a));
#define all(x) (x).begin(), (x).end()
#define FF fflush(stdout)
#define debug printf("Hello\n")
//why is my rating plummeting
int n, m, k, x, y, sum, cnt, ans, f[30];
char s[1000005], t[1000005];
int main () {
	int len=0;
	scanf("%s", s);
	n=strlen(s);
	for (int i=0; i<n; i++) {
		f[s[i]-'a']++;
		bool ok=true;
		for (int j=0; j<26; j++) {
			if (!f[j])  {
				ok=false;
				break;
			}
		}
		if (ok) {
			//printf("%d %c\n", i, s[i]);
			len++;
			memset(f, 0, sizeof f);
		}
	}
	len++;
	for (int i=0; i<len; i++) t[i]='a';
	while (true ){
		int match=0;
		for (int i=0; i<n; i++) {
			if (s[i]==t[match]) {
				match++;
				if (match==len) break;
			}
		}
		if (match!=len) {
			printf("%s\n", t);
			return 0;
		}
		int ind=len-1;
		t[ind]++;
		while (t[ind]>'z') {
			t[ind]='a';
			ind--;
			t[ind]++;
		}
	}
	return 0;
}