import Data.List

main = do
  s <- getLine
  k <- readLn
  putStrLn $ (f [] (sort (init (tails s))) 5) !! (k-1)

f acc _ 0 = acc
f acc (x:xs) n
  | las >= n  = acc ++ take n as
  | otherwise = f (acc ++ as) xs (n-las)
  where 
    as = filter (`notElem` acc) (tail (inits x))
    las = length as