main = do
  s <- getLine
  line <- getLine
  let
    k = read $ head $ words line :: Int
    func :: [[Char]] -> Int -> Int -> [Char]
    func xs ln i
      | ln+i > length s = func xs (ln - 1) 0
      | ln == 0         = head xs
      | otherwise       = func (cut $ ins xs $ subs s ln i) ln (i+1)
    ins xs str
      | xs == []        = str : []
      | head xs > str   = head xs : ins (tail xs) str
      | head xs == str  = xs
      | otherwise       = str : xs
    cut xs
      | length xs > k   = tail xs
      | otherwise       = xs
    subs str ln i 
      | i > 0     = subs (tail str) ln (i - 1)
      | ln > 0    = head str : subs (tail str) (ln - 1) i
      | otherwise = []
    in
      putStrLn $ show $ func [] (length s) 0
