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: Accepted)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long lint;

const int INF = 0x3f3f3f3f;
const lint INFL = 0x3f3f3f3f3f3f3f3fLL;

template<typename T, typename U> void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> void amax(T &x, U y) { if (x < y) x = y; }

const int N = 26;

vector<vector<int>> graph;
vector<int> pre;
string str;

string back(int u, int last) {
	stack<char> S;
	while (u) {
		S.push(str[u - 1]);
		u = pre[u];
	}
	string ans;
	while (!S.empty()) {
		ans += S.top();
		S.pop();
	}
	ans += 'a' + last;
	return ans;
}

string bfs() {
	queue<int> Q;
	Q.push(0);
	while (!Q.empty()) {
		int u = Q.front();
		Q.pop();
		for (int i = 0; i < N; i++) {
			int v = graph[u][i];
			if (v == -1) return back(u, i);
			if (pre[v] == -1) {
				pre[v] = u;
				Q.push(v);
			}
		}
	}
}

bool solve(int testNumber) {
	if (!(cin >> str)) return false;
	int n = str.size();
	graph.assign(n + 1, vector<int>(N));
	vector<int> nex(N, -1);
	pre.assign(n + 1, -1);
	for (int i = n; i >= 0; i--) {
		for (int j = 0; j < N; j++) graph[i] = nex;
		if (i) nex[str[i - 1] - 'a'] = i;
	}
	string ans = bfs();
	printf("%s\n", ans.c_str());
	return true;
}

void init(const char *in = nullptr, const char *out = nullptr) {
	if (in) freopen(in, "r", stdin);
	if (out) freopen(out, "w", stdout);
}

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(nullptr);
	init();
	for (int i=1; solve(i); i++);
	return 0;
}