fun main(args: Array<String>) {
  val s = readLine()!!
  val k = readLine()!!.toInt()
  val list = mutableListOf<String>()
  for (i in 0 until s.length) {
    for (l in 1..k) {
      if (i + l > s.length) continue
      val t = s.substring(i, i + l)
      list.add(t)
    }
  }
  val uniqueSortedList = list.toSet().toList().sorted()
  println(uniqueSortedList[k - 1])
}
