#include<iostream>
#include <bits/stdc++.h>

using namespace std;

int main(){
  
  string s;
  cin>>s;
  
  int k;
  cin>>k;
  int mlen=1, len=1;
  string ans = "";
  ans.push_back(s[0]);
  string temp = "";
  temp.push_back(s[0]);
  for(int i=1; i<s.size(); i++){
  	if(abs(s[i]-s[i-1])<=k){
  		len++;
  		temp.push_back(s[i]);
  		if(len>mlen){
  			mlen=len;
  			ans=temp;
  		}
  	}
  	else{
  		len=1;
  		temp="";
  	}
  }
  
  cout<< ans;
  return 0;
}