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: Runtime Error)

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 Solve(S *[][]int, N int) string {
  LC := "abcdefghijklmnopqrstuvwxyz"
  W := make([][]int, 6)
  W[0] = []int{0}
  for i, w := range W {
    W[i + 1] = make([]int, len(w) * 26)
    for j, v := range w {
      for k, s := range LC {
        value := (*S)[int(s) - int('a')][v]
        if value < 0 {
          key := make([]rune, i + 1)
          key[i] = s
          for l := i; 0 < l; l-- {
            key[l - 1] = rune(int('a') + j % 26)
            j /= 26
          }
          return string(key)
        }
        W[i + 1][j * 26 + k] = value
      }
    }
  }
  return ""
}

func main() {
  A := NextLine()
  S := make([][]int, 26)
  N := len(A)
  for i := range S {
    S[i] = make([]int, N + 1)
    S[i][N] = -1
  }
  for i, a := range A {
    s := int(a) - int('a')
    S[s][i] = i + 1
  }
  for i := range S {
    for j := range S[i][1:] {
      if S[i][N - 1 - j] == 0 { S[i][N - 1 - j] = S[i][N - j] }
    }
  }
  Write(Solve(&S, N))
  Output()
}