object Main extends App {
  val s, ks = scala.io.StdIn.readLine
  val k = ks.toInt
  val ss = (0 to s.size - 1).map(i => s.slice(i, i + k)).sorted
  println(if (s.size < 5) {
    val sorted = ss.flatMap(_.inits).distinct.sorted.tail // remove "" by tail
    sorted(k - 1)
  } else {
    ss.head
  })
}