fun main(args: Array<String>) {
    val s = readLine()!!
    val k = readLine()!!.toInt()
    val ss = sortedSetOf<String>()
    for (i in 0 until s.length) {
        for (j in i + 1..Math.min(i + k, s.length)) {
            ss += s.substring(i, j)
        }
    }
    var i = 1
    for (x in ss) {
        if (i++ != k) continue
        println(x)
        break
    }
}
