#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

using PII = pair<int, int>;
using TI3 = tuple<int, int, int>;
using LL = long long;
using ULL = unsigned long long;
using MAT = array<array<LL, 2>, 2>;

template<class T> constexpr inline T begin(const T&) {return 0;}
template<class T> constexpr inline T end(const T& x) {return x;}

#define PN() putchar('\n')
#define PB push_back
#define EB emplace_back
#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define CHECK(a,b) static_assert(std::is_same<decltype(a), decltype(b)>::value, "REP diff types");

#define REPPP(i,s,c,t) for(i; ((s) and (c)) or (putchar("\n "[c]) and (c)); (t))
#define REPP2(i,n) REPPP(auto i=begin(n),i==begin(n),i!=end(n),++i)
#define REPP3(i,m,n) CHECK(m,n) REPPP(auto i=(m),i==(m),i<(n),++i)
#define REPP4(i,m,n,s) CHECK(m,n) REPPP(auto i=(m),i==(m),((s)>0 and i<(n)) or ((s)<0 and i>(n)),i+=(s))
#define REPP(...) GET_MACRO(__VA_ARGS__, REPP4, REPP3, REPP2)(__VA_ARGS__)

#define REP2(i,n) for(auto i=begin(n);i!=end(n);++i)
#define REP3(i,m,n) CHECK(m,n) for(auto i=(m);i<(n);++i)
#define REP4(i,m,n,s) CHECK(m,n) for(auto i=(m);((s)>0 and i<(n)) or ((s)<0 and i>(n));i+=(s))
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)

template<class T> void _read(T &x) {cin>>x;}
void _read(size_t &x) {scanf("%zu", &x);}
void _read(int &x) {scanf("%d", &x);}
void _read(LL &x) {scanf("%lld", &x);}
void _read(ULL &x) {scanf("%llu", &x);}
void _read(double &x) {scanf("%lf", &x);}
void _read(char &x) {scanf(" %c", &x);}
void _read(char *x) {scanf("%s", x);}
void read() {}
template<class T, class... U>
void read(T& head, U&... tail) {
    _read(head);
    read(tail...);
}

template<class T> void _print(const T &x) {cout << x;}
void _print(const size_t &x) {printf("%zu", x);}
void _print(const int &x) {printf("%d", x);}
void _print(const LL &x) {printf("%lld", x);}
void _print(const ULL &x) {printf("%llu", x);}
void _print(const double &x) {printf("%.16lf",x);}
void _print(const char &x) {putchar(x);}
void _print(const char *x) {printf("%s",x);}
template<class T> void _print(const vector<T> &x) {
    for(auto i = x.begin(); i != x.end(); _print(*i++)) {
        if (i != x.cbegin()) putchar(' ');
    }
}
void print() {}
template<class T, class... U> void print(const T& head, const U&... tail) {
    _print(head);
    putchar(sizeof...(tail) ? ' ' : '\n');
    print(tail...);
}

#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f

const int MOD = 1000000007;
#define MAX_N 300005

vector<int> construct_sa(const string& s) {
    int n = int(s.size());
    vector<int> sa(n + 1), tmp(n + 1), rnk(n + 1);

    for(int i = 0; i <= n; i++) {
        sa[i] = i;
        rnk[i] = i < n ? s[i] : -1;
    }

    for(int k = 1; k <= n; k <<= 1) {
        auto cmp = [&](const int i, const int j) {
            if(rnk[i] != rnk[j]) {
                return rnk[i] < rnk[j];
            }
            int ri = (i + k <= n)? rnk[i + k] : -1;
            int rj = (j + k <= n)? rnk[j + k] : -1;
            return ri < rj;
        };
        sort(sa.begin(), sa.end(), cmp);

        tmp[sa[0]] = 0;
        for(int i = 1; i <= n; i++) {
            tmp[sa[i]] = tmp[sa[i - 1]] + int(cmp(sa[i-1], sa[i]));
        }
        swap(rnk, tmp);
    }
    return sa;
}

vector<int> construct_lcp(const string& s, vector<int>& sa) {
    int n = s.size();
    vector<int> rnk(n + 1), lcp(n + 1);
    for(int i = 0; i <= n; i++) {
        rnk[sa[i]] = i;
    }
    int h = 0;
    lcp[0] = 0;
    for(int i = 0; i < n; i++) {
        int j = sa[rnk[i] - 1];
        if(h > 0) {
            --h;
        }
        for(; j + h < n and i + h < n; h++) {
            if(s[j + h] != s[i + h]) {
                break;
            }
        }
        lcp[rnk[i] - 1] = h;
    }
    return lcp;
}

char tmp[5005];

int main()
{
    read(tmp);
    string s(tmp);
    int k;
    read(k);

    vector<int> sa = construct_sa(s);
    vector<int> lcp = construct_lcp(s, sa);
    int n = int(s.size());
    REP(i, 1, n + 1) {
        if(n - (sa[i] + lcp[i - 1]) >= k) {
            print(s.substr(sa[i], lcp[i - 1] + k));
            break;
        }
        k -= n - (sa[i] + lcp[i - 1]);
    }
    return 0;
}


Measured memory_bytes: 384