import Data.List
ans 0 s = s
ans _ [] = []

ans k s@(s0:ss) =
  let (i,c) = minimumBy (\(i0,c0)(i1,c1) -> let cmp = compare i0 i1
                                            in
                                              if cmp /= EQ
                                              then compare c0 c1 
                                              else cmp ) $ zip [0..] $ take (k+1) s
      s' = (take i s) ++ (drop (i+1) s)
  in
    if i == 0
    then s0:(ans k ss)
    else c:(ans (k-i) s')

main = do
  s <- getLine
  k <- getLine
  let k' = read k :: Int
      o  = ans k' s
  putStrLn o

