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 Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)

import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    sc.close();
    final char[] chars = "abcdefghijklmnopqrstuvwxyz".toCharArray();
    int[] rchars = new int[chars.length];
    Arrays.fill(rchars, 0);

    char[] arr  = a.toCharArray();
    int [] rarr = new int[arr.length];
    for (int i=arr.length; i>0; i--) {
      int rank=rchars[0];
      for (int j=1;j<rchars.length;j++)
        rank = Math.min(rank, rchars[j]);

      int idx=i-1;
      char c = arr[idx];
      rchars[c-'a']=rank+1;
      rarr[idx]=rank+1;
    }

    int rank=rchars[0];
    for (int j=1;j<rchars.length;j++)
      rank = Math.min(rank, rchars[j]);
    StringBuffer sb = new StringBuffer(rank+1);

    int idx=0;
    while (idx<arr.length) {
      loop: for (int j=0;j<chars.length;j++) {
        char c = chars[j];
        boolean flag=true;
        for (int i=idx;i<arr.length;i++) {
          if (arr[i]==c) {
            if (rarr[i]==rank) {
              sb.append(c);
              rank--;
              idx=i+1;
              break loop;
            } else {
              flag = false;
              break;
            }
          }
        }
        if (flag) {
          sb.append(c);
          idx=arr.length;
          break loop;
        }
      }
    }
    System.out.println(sb.toString());
  }
}