#include<iostream>
#include<stack>
using namespace std;
int main(){
stack<char> s;
stack<char> l;
int k;
string a;
cin>>a>>k;
s.push(a[0]);
for(int i=1;i<a.size();i++){
if(a[i]>s.top()&&k>0){
s.pop();
s.push(a[i]);
k--;
}
}
while(!s.empty()){
l.push(s.top());
s.pop();
}
while(!l.empty()){
cout<<l.top();
l.pop();
}
}