fun c97(args: Array<String>) {
    val s = args[0]
    val K = args[1].toInt()

    val strSet = mutableSetOf<String>()
    (1..K).forEach { len ->
        (0..s.length - len).forEach { start ->
            strSet.add(s.substring(start, start + len))
        }
    }

    println(strSet.sorted().drop(K - 1).first())
}

fun main(args: Array<String>) {
    c97(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}