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 Go (1.6) (judge verdict: Wrong Answer)

package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func Min(x, y int) int {
  if x < y { return x }
  return y
}

func main() {
  A := NextLine()
  S := make([][]int, 26)
  N := len(A)
  for s := range S {
    S[s] = make([]int, N + 1)
    S[s][N] = N + 1
  }
  for i, a := range A {
    s := int(a) - int('a')
    S[s][i] = i + 1
  }
  for s := range S {
    for i := N; 0 < i; i-- {
      if S[s][i - 1] == 0 { S[s][i - 1] = S[s][i] }
    }
  }
  M := make([]int, N + 2)
  for i := range M[1:] {
    M[i + 1] = -1
  }
  for i, m := range M[:N + 1] {
    for s := range S {
      t, k := S[s][i], m * 27 + (s + 1)
      if M[t] < 0 { M[t] = k }
      M[t] = Min(k, M[t])
    }
  }
  ans := make([]rune, 0)
  for 0 < M[N + 1] {
    if 0 < len(ans) {
      ans = append(ans[0:1], ans[0:]...)
      ans[0] = rune((M[N + 1] % 27) + 96)
    } else {
      ans = append(ans, rune((M[N + 1] % 27) + 96))
    }
    M[N + 1] /= 27
  }
  Write(string(ans))
  Output()
}