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 Haskell (GHC 7.10.3) (judge verdict: Time Limit Exceeded)

import Control.Applicative
import Data.Monoid
import Data.List

data Subsequence = Subsequence
    { str :: String
    , indicies :: [Int] } deriving Show

emptySubseq :: Subsequence
emptySubseq = Subsequence "" []

allStrings :: [String] -> [String]
allStrings alphabet =  alphabet <> ((++) <$> allStrings alphabet <*> alphabet)

dict = allStrings $ map (: []) ['a'..'z']

{-
insertAndReturnSeqIdx :: Int -> [Int] -> Int -> ([Int], Int)
insertAndReturnSeqIdx i [] a = ([i], a)
insertAndReturnSeqIdx i ix a
    | i < head ix = (i : ix, a)
    | not $ null ix = let
        (res, newA) = insertAndReturnSeqIdx i (tail ix) (a + 1) in
        (head ix : res, newA)
    | null ix = ([i], a)

-- recurrence relation between subsequences
-- TODO: Tabulation
reccur :: V.Vector Char -> Subsequence -> Int -> Subsequence
reccur input prevSeq idx = Subsequence newStr newIndicies
      where (newIndicies, seqIdx) =
                insertAndReturnSeqIdx idx (indicies prevSeq) 0
            (front, end) = splitAt seqIdx $ str prevSeq
            newStr = front ++ ((input V.! idx) : end)

isSubseq Subsequence sx = 
-}

{-
search :: V.Vector Char -> String -> Either String Int
search input target = do
    let limit = length target
    let inputLen = V.length input
    map 
-}

search :: String -> [String] -> String
search input dict
    | isSubsequenceOf (head dict) input = search input (tail dict)
    | otherwise = head dict


{-
solve :: V.Vector Char -> Int
solve input = 
-}
    

main = do
    --input <- V.fromList <$> getLine
    input <- getLine
    let res = search input dict
    putStrLn res