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 Lua (5.3.2) (judge verdict: Wrong Answer)

local s = io.read()
local n = #s
local t = {}
for i = 1, n do t[i] = s:sub(i, i):byte() - 96 end
local endpos = {}
local box = {}
local bc = 0
local function clearbox()
  for i = 1, 26 do
    box[i] = false
  end
  bc = 0
end
clearbox()
for i = 1, n do
  if not box[t[i]] then
    box[t[i]] = true
    bc = bc + 1
  end
  if bc == 26 then
    table.insert(endpos, i)
    clearbox()
  end
end
clearbox()
if #endpos == 0 then
  for i = 1, n do
    box[t[i]] = true
  end
  for i = 1, 26 do
    if not box[i] then
      print(string.char(96 + i))
      break
    end
  end
else
  local ret = {"a"}
  local prv = 0
  for i = 1, n do if t[i] == 1 then prv = i break end end
  for i = 1, #endpos do
    clearbox()
    for j = prv + 1, endpos[i] do
      box[t[j]] = true
    end
    for j = 1, 26 do
      if not box[j] then
        table.insert(ret, string.char(96 + j))
        for k = endpos[i] + 1, n do
          if t[k] == j then
            prv = k
            break
          end
        end
        break
      end
    end
  end
  print(table.concat(ret))
end