You are given a string s consisting of n lowercase Latin letters. Polycarp wants to remove exactly k characters (k≤n) from the string s. Polycarp uses the following algorithm k times:
- if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
- if there is at least one letter 'b', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
- ...
- remove the leftmost occurrence of the letter 'z' and stop the algorithm.
This algorithm removes a single letter from the string. Polycarp performs this algorithm exactly k times, thus removing exactly k characters.
Help Polycarp find the resulting string.
Input
The first line of input contains two integers n and k (1≤k≤n≤4⋅105) — the length of the string and the number of letters Polycarp will remove.
The second line contains the string s consisting of n lowercase Latin letters.
Output
Print the string that will be obtained from s after Polycarp removes exactly k letters using the above algorithm k times.
If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).
Examples
Input 1
15 3 cccaabababaccbc
Output 1
cccbbabaccbc
Input 2
15 9 cccaabababaccbc
Output 2
cccccc
Input 3
1 1 in
Output 3
Ideas:
Analogy bucket sort with the number of buckets stored letter
Code:
1 #include <stdio.h> 2 #include <string.h> 3 #include <iostream> 4 #include <string> 5 #include <math.h> 6 #include <algorithm> 7 #include <vector> 8 #include <stack> 9 #include <queue> 10 #include <set> 11 #include <map> 12 #include <math.h> 13 const int INF=0x3f3f3f3f; 14 typedef long long LL; 15 const int MOD = 1E9 + . 7 ; 16 const int MAXN = . 4 * 1E5 + 10 ; . 17 the using namespace STD; 18 is . 19 char STR [MAXN]; 20 is int CNT [ 27 ]; // number of original letters 21 is int NUM [ 27 ] ; // number of letters treatment 22 is 23 is int main () 24 { 25 int n-, K; 26 is Scanf ( " % D% D " , & n-, & K); 27 getchar(); 28 for(int i=0;i<n;i++) 29 { 30 scanf("%c",&str[i]); 31 cnt[str[i]-'a'+1]++; 32 num[str[i]-'a'+1]++; 33 } 34 str[n]=0; 35 for(int i=1;i<=26; I ++) // 'a' and the k-th process starts 36 { 37 [ the while (NUM [I] && k) 38 is { 39 NUM [I] - ; 40 K-- ; 41 is } 42 is } 43 is for ( int I = 0 ; STR [I]; I ++ ) 44 is { 45 IF (CNT [STR [I] - ' A ' + . 1 ]> NUM [STR [I] - ' A ' + . 1 ]) // description of the position of the letters is delete 46 { 47 CNT [STR [I] - ' A ' + . 1 ] - ; 48 Continue ; 49 } 50 the else // If this is not the position of the letter is deleted, the output of the letter 51 is the printf ( " % C " , STR [I] ); 52 is } 53 is return 0 ; 54 is }