import Data.List
import Debug.Trace

main = do
  s <- getLine
  k <- read <$> getLine :: IO Int
  putStrLn $ (sort $ nub $ subseq s [])!!k

subseq :: String -> [[String]] -> [String]
subseq [] acc = concat acc
subseq s acc=
--  traceShow acc $
  subseq (tail s) $ inits s : acc
