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

void main()
{
  auto s = readln.strip;
  long x;
  readf("%d", &x);

  int[string] dict;
  foreach (i; 0..s.length) {
    foreach (j; (i+1)..s.length+1) {
      dict[s[i..j]] = 1;
    }
  }
  auto subs = dict.keys.sort().array();
  writeln(subs[x-1]);
}
