#include <bits/stdc++.h>

using namespace std;

ifstream fi("XAUMAX.inp");
ofstream fo("XAUMAX.out");

string s;
int n;

int main(){
  std::getline(fi,s);
  fi>>n;
  int i;
  for (i=0;i<s.length();i++){
    while(int(s[i])<48||int(s[i])>57){s.erase(i,1);n--;}
  }
  if (n==0){fo<<s;}
  else {
  string ma, s2,m;
  s2=s;
  ma=s2.erase(0,1);
  while (n>0){
  for (i=0;i<s.length();i++){
    s2=s;
    m=s2.erase(i,1);
    if (m>ma){ma=m;}
  }
  s=ma; n--;
  }
  fo<<ma;
}
}
