fun main(args: Array<String>) {
    val s = readLine()!!
    val K = readLine()!!.toInt()

    val l = mutableListOf<String>()
    for (c in 0..s.length) for (d in 1..(s.length - c)) {
        val t = s.substring(c, c + d)
        if (5 < t.length) break
        if (!l.contains(t)) l += t
    }

    println(l.sorted()[K - 1])
}