import Data.List

substrings s = concat [substrings' s i | i<-[1..(min 5 (length s))]]
  where
    substrings' s@(x:xs) i
      | length s == i = [s]
      | otherwise = (take i s) : (substrings' xs i)

main = do
  s <- getLine
  k <- readLn :: IO Int

  putStrLn $ (solve [] (substrings s)) !! (k-1)
  
  where
    solve :: [String] -> [String] -> [String]
    solve sorted [] = sorted
    solve sorted (x:xs) = solve s xs
      where s = sort' sorted x

    sort' sorted x
      | elem x sorted = sorted
      | length sorted < 5 = sort $ x:sorted
      | last sorted <= x = sorted
      | otherwise = init (sort $ x:sorted)
