import java.util.Scanner

import scala.collection.mutable

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val s = sc.next
    val K = sc.nextInt

    val ss = new mutable.HashSet[String]()

    for (i <- 0 until s.length; j <- i + 1 to Array(i + K, s.length).min) {
      ss += s.substring(i, j)
    }

//    ss.toList.sorted.foreach(println)
    ss.toList.sorted.take(K).last
  }
}
