#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl;
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl;
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl;
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl;
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl;
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl;
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<60;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

typedef vector<int> V;
typedef vector<V> VV;
class Len{
public:
  string str;
  VV mem, used;
  
  Len(){}
  Len(string str):str(str),mem(2010,V(2010,0)),used(2010,V(2010,0)){dfs(0,str.size()-1);}
  
  int dfs(int l,int r){
    if(l == r) return 1;
    if(l > r) return  0;
    if(used[l][r]++) return mem[l][r];
    
    int res = INF;
    if(str[l] == str[r]) res = 2 + dfs(l+1, r-1);
    Min(res, 2 + dfs(l + 1, r));
    Min(res, 2 + dfs(l, r - 1));
    return mem[l][r] = res;
  }
};


class Cnt{
public:
  string str;
  Len len;
  VV mem,used;
  Cnt(){}
  Cnt(string str):str(str),len(str),mem(2010,V(2010,0)),used(2010,V(2010,0)){
    dfs(0,str.size()-1);
    used = VV(2010,V(2010,1));
  }
  
  int dfs(int l,int r){ //[l,r]
    if(l >= r) return 1;
    if(used[l][r]++) return mem[l][r];
    
    int mn = len.dfs(l, r);
    int a = 0, b = 0, c = 0;
    if(str[l] == str[r] && mn == len.dfs(l+1, r-1) + 2) a =  dfs(l+1, r-1);
    else {
      if(mn == len.dfs(l+1, r) + 2) b = dfs(l+1, r);
      if(mn == len.dfs(l, r-1) + 2) c = dfs(l, r-1);
    }
    int res = min(INF, a + min(INF, b + c));
    return mem[l][r] = res;
  }
};


string str;
Cnt cnt;
string ans;
void dfs(int l,int r,int K){
  if(l == r) {ans += str[l]; return;}
  if(l > r) return;
  int mn = cnt.len.dfs(l, r);
  
  auto add=[](char ch){ans += ch;};
  
  auto A=[&](){
    if(K <= 0) return ;
    int a = cnt.dfs(l+1,r-1);
    if(a >= K) add(str[l]), dfs(l+1, r-1, K), add(str[l]);
    K -= a;
  };
  
    auto B=[&](){
    if(K <= 0) return ;
    if(mn != cnt.len.dfs(l + 1, r) + 2) return;
       
    int a = cnt.dfs(l+1, r);
    if(a >= K) add(str[l]), dfs(l+1, r, K), add(str[l]);
    K -= a;
  };

  auto C=[&](){
    if(K <= 0) return ;
    if(mn != cnt.len.dfs(l, r-1) + 2) return;
    int a = cnt.dfs(l, r-1);
    if(a >= K) add(str[r]), dfs(l, r-1, K), add(str[r]);
    K -= a;
  };
  
  if(str[l] == str[r]) A();
  if(str[l] < str[r]) B(), C();
  if(str[l] > str[r]) C(), B();
}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  int K;
  cin >>str >> K;
  cnt = Cnt(str);
  int n = str.size();
  if(cnt.dfs(0, n-1) < K){cout<<"NONE"<<endl;return 0;}
  
  dfs(0,n-1,K);
  assert((int)ans.size() == cnt.len.dfs(0,n-1));
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 161644