#include <bits/stdc++.h>
using namespace std;
int main() {
string str;
cin>>str;
int k;
cin>>k;
int n=str.size();
vector<int> dp(n);
dp[0]=1;
for(int i=1;i<n;i++){
if(abs(str[i]-str[i-1])<=k){
dp[i]=dp[i-1]+1;
}else{
dp[i]=1;
}
}
int maxInd =0;
int maxLen= 1;
for(int i=1;i<n;i++){
if(dp[i]>maxLen){
maxLen = dp[i];
maxInd = i;
}
}
cout<<str.substr(maxInd-maxLen+1,maxLen);
return 0;
}//RRRRR
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKaW50IG1haW4oKSB7CiAgICBzdHJpbmcgc3RyOwogICAgY2luPj5zdHI7CiAgICBpbnQgazsKICAgIGNpbj4+azsKICAgIGludCBuPXN0ci5zaXplKCk7CiAgICB2ZWN0b3I8aW50PiBkcChuKTsKICAgIGRwWzBdPTE7CiAgICBmb3IoaW50IGk9MTtpPG47aSsrKXsKICAgIAlpZihhYnMoc3RyW2ldLXN0cltpLTFdKTw9ayl7CiAgICAJCWRwW2ldPWRwW2ktMV0rMTsKICAgIAl9ZWxzZXsKICAgIAkJZHBbaV09MTsKICAgIAl9CiAgICB9CiAgICBpbnQgbWF4SW5kID0wOwogICAgaW50IG1heExlbj0gMTsKICAgIGZvcihpbnQgaT0xO2k8bjtpKyspewogICAgCWlmKGRwW2ldPm1heExlbil7CiAgICAJCW1heExlbiA9IGRwW2ldOwogICAgCQltYXhJbmQgPSBpOwogICAgCX0KICAgIH0KICAgIGNvdXQ8PHN0ci5zdWJzdHIobWF4SW5kLW1heExlbisxLG1heExlbik7CiAgICByZXR1cm4gMDsKfS8vUlJSUlI=