import Data.List (nub, sort)

inits :: Int -> [a] -> [[a]]
inits 0 _ = []
inits _ [] = []
inits k (x:xs) = map (x:) ([] : inits (k-1) xs)

tails :: [a] -> [[a]]
tails [] = []
tails xs = xs : tails (tail xs)

substrings :: Int -> String -> [String]
substrings k = concatMap (inits k) . tails

solve :: Int -> String -> String
solve k = (!! (k-1)) . sort . nub . substrings k

main :: IO ()
main = do
  s <- getLine
  k <- read <$> getLine
  putStrLn $ solve k s
