object Main extends App {
  
  def substrList(s: String)(startindex: Int): Seq[String] = 
    (startindex + 1 to s.length).map(l => s.slice(startindex, l))
  
  val (s, k) = (readLine, readInt)
  val ans = s.zipWithIndex
    .groupBy(_._1)
    .toSeq
    .sortBy(_._1)
    .toStream
    .flatMap {
      case (_: Char, indices: Seq[(Char, Int)]) =>
        indices
          .map(_._2)
          .flatMap(substrList(s))
          .distinct
          .sorted
          .toStream
    }
    .take(k)
    .last
  
  println(ans)
}