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: Wrong Answer)

using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        int[] nextCharIndex = new int[s.Length];
        int[] eachLength = new int[26];
        int[] nextIndex = Enumerable.Repeat(s.Length, 26).ToArray();
        int min;
        for (int i = s.Length - 1; i >= 0; i--)
        {
            var elem = s[i] - 'a';
            nextIndex[elem] = i;
            min = eachLength.Where((x,y) => y != elem).Min();
            for (int j = 0; j < 26; j++)
            {
                if (elem != j && eachLength[j] == min)
                {
                    nextCharIndex[i] = nextIndex[j];
                    eachLength[elem] = eachLength[j] + 1;
                    break;
                }
            }
        }
        min = eachLength.Min();
        for (int i = 0; i < 26; i++)
        {
            if(eachLength[i] == min)
            {
                StringBuilder builder = new StringBuilder();
                var currentInd = nextIndex[i];
                while (currentInd < s.Length)
                {
                    builder.Append(s[currentInd]);
                    currentInd = nextCharIndex[currentInd];
                }
                builder.Append('a');
                Console.WriteLine(builder.ToString());
                break;
            }
        }
    }
}