a = gets.chomp.split("")
n = gets.to_i
def f(a, n)
    return a if n == 0
    return a if a == []
    c = a[0]
    m = a[0..[a.size-1, n].min].min
    i = a.index(m)
    b = (i == 0 ? [] : a[0..i-1]) + a[i+1..-1]
    return [m] + f(b, n - i)
end
puts f(a, n).join
