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 <stdio.h>
#include <stdlib.h>
#include <string.h>

char shortage(char *str) {
	int i, alpha[26] = {0}, count = 0;
	for (i = 0; str[i] != '\0'; i++) {
		if (alpha[str[i] - 'a'] == 0) {
			alpha[str[i] - 'a'] = 1;
			count++;
		}
		if (count == 26)
			return '\0';
	}
	for (i = 0; i < 26; i++) {
		if (alpha[i] == 0)
			return 'a' + i;
	}
	return '\0';
}

int find(char *str, char c) {
	int i;
	for (i = 0; str[i] != '\0'; i++) {
		if (str[i] == c)
			return i;
	}
	return -1;
}

char A[200001];

int main(void) {
	int i, j, k, index;
	scanf("%s", A);

	char ans = shortage(A);
	if (ans != '\0') {
		printf("%c", ans);
		return 0;
	}

	for (i = 'a'; i <= 'z'; i++) {
		index = find(A, i);
		ans = shortage(A + index + 1);
		if (ans != '\0') {
			printf("%c%c",i, ans);
			return 0;
		}
	}

	for (i = 'a'; i <= 'z'; i++) {
		index = find(A, i);
		for (j = 'a'; j <= 'z'; j++) {
			index += find(A + index + 1, j);
			ans = shortage(A + index + 1);
			if (ans != '\0') {
				printf("%c%c%c", i, j, ans);
				return 0;
			}
		}
	}

	for (i = 'a'; i <= 'z'; i++) {
		index = find(A, i);
		for (j = 'a'; j <= 'z'; j++) {
			index += find(A + index + 1, j);
			for (k = 'a'; k <= 'z'; k++) {
				index += find(A + index + 1, k);
				ans = shortage(A + index + 1);
				if (ans != '\0') {
					printf("%c%c%c%c", i, j, k, ans);
					return 0;
				}
			}
		}
	}

	return 0;
}