#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) ((n%m + m) % m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

// Begins Suffix Arrays implementation
// O(n log n) - Manber and Myers algorithm
// Refer to "Suffix arrays: A new method for on-line string searches",
// by Udi Manber and Gene Myers

//Usage:
// Fill str with the characters of the string.
// Call SuffixSort(n), where n is the length of the string stored in str.
// That's it!

//Output:
// sa = The suffix array. Contains the n suffixes of str sorted in lexicographical order.
//       Each suffix is represented as a single integer (the saition of str where it starts).
// rank = The inverse of the suffix array. rank[i] = the index of the suffix str[i..n)
//        in the sa array. (In other words, sa[i] = k <==> rank[k] = i)
//        With this array, you can compare two suffixes in O(1): Suffix str[i..n) is smaller
//        than str[j..n) if and only if rank[i] < rank[j]

const int N = 1e5 + 5;
int str[N]; //input
int rnk[N], sa[N]; //output
int cnt[N], nxt[N]; //internal
bool bh[N], b2h[N];

// Compares two suffixes according to their first characters
bool smaller_first_char(int a, int b)
{
	return str[a] < str[b];
}

void suffixArray(int n)
{
	//sort suffixes according to their first characters
	for (int i = 0; i < n; ++i)
	{
		sa[i] = i;
	}
	sort(sa, sa + n, smaller_first_char);
	//{sa contains the list of suffixes sorted by their first character}

	for (int i = 0; i < n; ++i)
	{
		bh[i] = i == 0 || str[sa[i]] != str[sa[i - 1]];
		b2h[i] = false;
	}

	for (int h = 1; h < n; h <<= 1)
	{
		//{bh[i] == false if the first h characters of sa[i-1] == the first h characters of sa[i]}
		int buckets = 0;
		for (int i = 0, j; i < n; i = j)
		{
			j = i + 1;
			while (j < n && !bh[j])
				j++;
			nxt[i] = j;
			buckets++;
		}
		if (buckets == n)
			break; // We are done! Lucky bastards!
		//{suffixes are separted in buckets containing strings starting with the same h characters}

		for (int i = 0; i < n; i = nxt[i])
		{
			cnt[i] = 0;
			for (int j = i; j < nxt[i]; ++j)
			{
				rnk[sa[j]] = i;
			}
		}

		cnt[rnk[n - h]]++;
		b2h[rnk[n - h]] = true;
		for (int i = 0; i < n; i = nxt[i])
		{
			for (int j = i; j < nxt[i]; ++j)
			{
				int s = sa[j] - h;
				if (s >= 0)
				{
					int head = rnk[s];
					rnk[s] = head + cnt[head]++;
					b2h[rnk[s]] = true;
				}
			}
			for (int j = i; j < nxt[i]; ++j)
			{
				int s = sa[j] - h;
				if (s >= 0 && b2h[rnk[s]])
				{
					for (int k = rnk[s] + 1; !bh[k] && b2h[k]; k++)
						b2h[k] = false;
				}
			}
		}
		for (int i = 0; i < n; ++i)
		{
			sa[rnk[i]] = i;
			bh[i] |= b2h[i];
		}
	}
	for (int i = 0; i < n; ++i)
	{
		rnk[sa[i]] = i;
	}
}
// End of suffix array algorithm

// Begin of the O(n) longest common prefix algorithm
// Refer to "Linear-Time Longest-Common-Prefix Computation in Suffix
// Arrays and Its Applications" by Toru Kasai, Gunho Lee, Hiroki
// Arimura, Setsuo Arikawa, and Kunsoo Park.
int lcp[N];
// lcp[i] = length of the longest common prefix of suffix sa[i] and suffix sa[i-1]
// lcp[0] = 0
void getlcp(int n)
{
	for (int i = 0; i < n; ++i)
		rnk[sa[i]] = i;
	lcp[0] = 0;
	for (int i = 0, h = 0; i < n; ++i)
	{
		if (rnk[i] > 0)
		{
			int j = sa[rnk[i] - 1];
			while (i + h < n && j + h < n && str[i + h] == str[j + h])
				h++;
			lcp[rnk[i]] = h;
			if (h > 0)
				h--;
		}
	}
}
// End of longest common prefixes algorithm

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	string x;
	cin >> x;
	rep(i, 0, sz(x))
		str[i] = x[i];
	int k;
	cin >> k;

	suffixArray(sz(x));
	getlcp(sz(x));
	int ans = 0, pos = 0, len = 0;
	rep(i, 0, sz(x))
	{
		int temp = sz(x) - sa[i] - lcp[i];
		if (ans + temp < k)
			ans += temp;
		else
		{
			pos = sa[i];
			len = ans + temp - k;
			len = lcp[i] + temp - len;
			break;
		}
	}

	cout << x.substr(pos, len) << endl;
	return 0;
}



Measured memory_bytes: 384