import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const s = readln.chomp;
    const K = readln.chomp.to!(long);
    string[] list;
    foreach (l; 0..s.length) {
        foreach (r; l+1..s.length+1) {
            list ~= s[l..r];
        }
    }
    list.sort!((a,b) => a < b).uniq.take(K).array.back.writeln;
}

