fun main(arr: Array<String>) {
    val s = readLine()!!
    val k = readLine()!!.toInt()
    var list = mutableSetOf<String>()
    for(i in s.indices) {
        for(j in (i+1..Math.min(i+5, s.length))) {
            list.add(s.substring(i,j))
        }
    }
    list = list.sorted().toMutableSet()
    println(list.sorted()[k-1])
}
