import scala.io.{StdIn => in}

object Main extends App {
  val s = in.readLine
  val k = in.readInt

  val ss = s.take(k)

  val res =
    for {
      i <- 0 until s.size
      end = s.size min i+k
      j <- i+1 to end
    } yield s.substring(i,j)

  val ans = res.distinct.sorted.take(k).last
  println(ans)
}