import java.util.*

class SumBit(private val size: Int){
    private val mArray = IntArray(size){0}
    fun sumAt(index:Int): Int {
        var sum = 0
        var idx = index
        while(idx >= 0){
            sum += mArray[idx]
            idx -= (idx + 1) and idx.inv()
        }
        return sum
    }
    fun incrementAt(index:Int) {
        var idx = index
        while (idx < size){
            mArray[idx]++
            idx += (idx + 1) and idx.inv()
        }
    }
}
fun main(args:Array<String>):Unit {
    val str = readLine()!!.trim()
    var k = readLine()!!.trim().toInt()
    val queues = Array(26){PriorityQueue<Int>()}
    for ((queue, c) in queues.zip('a' .. 'z')) {
        for (i in 0 until str.length){
            if (str[i] == c) queue.add(i)
        }
    }
    val res = StringBuilder()
    val bit = SumBit(str.length)
    loop@while(res.length < str.length) {
        for (i in 0 until 26){
            if (queues[i].isNotEmpty() && queues[i].peek() - bit.sumAt(queues[i].peek()) <= k) {
                k -= queues[i].peek() - bit.sumAt(queues[i].peek())
                res.append('a'.plus(i))
                bit.incrementAt(queues[i].poll())
                continue@loop
            }
        }
    }
    println(res.toString())
}
