fun main() {
    val s= readLine()!!
    val n=s.length
    val k= readLine()!!.toInt()
    var subs= mutableSetOf<String>()
    for (i in 0 until n){
        for (j in i until Math.min(n, i+k)){
            val sub=s.slice(i until j+1)
            subs.add(sub)
        }
    }
    println(subs.sorted()[k-1])
}