function Main (input) {
  const inputs = input.split(/\s/g);
  const str = inputs[0];
  const target = inputs[1] - 1;
  const max = str.length;
  const patterns = [str];

  for (var i = 0; i <= max; i += 1) {
    for (var j = 0; j <= max; j += 1) {
      if (i + j <= max) {
        patterns.push(str.substr(i, j));
      }
    }
  }
  const result = patterns
    .filter((value) => value)
    .sort()
    .filter((x, i, self) => self.indexOf(x) === i);


  console.log('%s', result[target]);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
