#include <bits/stdc++.h>
 
using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int > vi;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
 
#define ALL(x) (x).begin(), (x).end()
#define RESET(x) memset((x), 0, sizeof (x))
#define FOR(i, b, e) for ( int i = (b); i < (e); ++i)
#define RE(i, n) FOR(i, 0, (n))
#define FOREACH(i, x, y) for ( int i = (x); i <= (y); ++i)
#define two(X) (1<<(X))//NOTES:two(
#define contain(S,X) (((S)&two(X))!=0)//NOTES:contain(
#define chkmin(X, Y) (X) = min((X), (Y))
#define chkmax(X, Y) (X) = max((X), (Y))
#define sqr(X) ((X) * (X))
 
const ll maxn = (ll) 5e5 + 100;
const ll maxm = (ll) 1e6;
const int LOGN = 22;
const ll INF = 1e15+ 10;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = 1e-12;

struct SA {

vector <int> sa;
vector <int> rank;
vector <int> height;

void BuildAll(const string& s) {
    BuildSA(s);
    BuildHeight(s);
}

void BuildSA(const string& s) {  // O(n* logn * logn)
    int n = s.size();
    sa.resize(n + 1); fill(sa.begin(), sa.end(), 0);
    rank.resize(n + 1); fill(rank.begin(), rank.end(), 0);

    for (int i = 1; i <= n; ++i) sa[i] = i, rank[i - 1] = s[i - 1];

    vector<int > next(n + 1);
    for (int k = 1; k <= n; k *= 2) {
        auto Cmp = [&](int i, int j) {
            int ri = i + k <= n ? rank[i + k] : -1;
            int rj = j + k <= n ? rank[j + k] : -1;
            return make_pair(rank[i], ri) < make_pair(rank[j], rj);
        };
        sort(sa.begin(), sa.end(), Cmp);
        next[sa[0]] = 0;
        for (int i = 1; i <= n; ++i) {
            next[sa[i]] = next[sa[i - 1]] + Cmp(sa[i - 1], sa[i]);
        }
        rank.swap(next);
    }
}

void BuildHeight(const string& s) {
    int n = s.size();
    int k = 0;
    height.resize(n + 1);
    fill(height.begin(), height.end(), 0);

    for (int i = 0; i < n; ++i) {  // iterate origin string
        int j = sa[rank[i] - 1];
        while (s[i + k] == s[j + k])
            ++k;
        height[rank[i]] = k;
        if (k) --k; // height(rank[i + 1]) >= height(rank[i]) - 1
    }
}

int LCPLength(int offset) {
    int ans = 0;
    int tmp = sa.size();
    for (int i = rank[offset]; i > 0; --i) {
        if (height[i] == 0) break;
        // if (sa[i] < offset) continue;
        chkmin(tmp, height[i]);
        chkmax(ans, min(tmp, sa[i - 1] - offset));
    }
    tmp = sa.size();
    for (int i = rank[offset] + 1; i < sa.size(); ++i) {
        if (height[i] == 0) break;
        // if (sa[i] < offset) continue;
        chkmin(tmp, height[i]);
        chkmax(ans, min(tmp, sa[i] - offset));
    }
    return ans;
}

} sa;




int main() {
#ifndef ONLINE_JUDGE
   // freopen("in.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    string line;
    int k;
    while (cin >> line >> k) {
        int n = line.size();
        sa.BuildAll(line.c_str());
        set<string> d;
        for (int i = 1; i <= n; ++i) {
            string t = line.substr(sa.sa[i]);
            for (int j = 0; j < t.size(); ++j) {
                string s = t.substr(0, j + 1);
                // trace(s);
                d.insert(s);
                if (d.size() == k)
                    break;
            }
            if (d.size() == k)
                break;
        }
        cout << *d.rbegin() << endl;
    }

    return 0;
}

Measured memory_bytes: 384