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 C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  string s;
  cin>>s;
  int c=0;
  vector<int> ch(26,0);
  vector<int> ch2(26,0);
  int cnt;
  int id=0;
  while(true){
    c=0;
    cnt=0;
    for(int i=s.size()-1;i>=id;i--){
      c=(c|(1<<(s[i]-'a')));
      ch[s[i]-'a']++;
      if(c==67108863){
        c=0;
        for(int j=0;j<26;j++){
          if(ch[j]==1){
            break;
          }
        }
        ch=ch2;
        //for(int j=0;j<26;j++)ch[j]=0;
        cnt++;
      }
    }
    char x;
    for(int i=0;i<26;i++){
      if(!(c&(1<<i))){
        x='a'+i;
        cout<<x;
        break;
      }
    }
    for(int i=id;i<s.size();i++){
      if(s[i]==x){
        id=i+1;
        break;
      }
    }
    if(cnt==0){
      cout<<endl;
      return 0;
    }
  }
}