import Data.List

substrings :: String -> [String]
substrings "" = []
substrings s@(_:r) = (substrings' s) ++ (substrings r)
    where
        substrings' "" = []
        substrings' (c:r) = [c:""] ++ (map ((:)c) $ substrings' r)

pickup_small :: Ord a => Int -> [a] -> [a]
pickup_small n l = take' n $ sort $ nub l
    where
        take' n l = take (minimum [n, length l]) l

kth :: Int -> String -> String
kth k s = (foldr f [] $ substrings s) !! (k - 1)
    where
        f e r = pickup_small k (e:r)

main = do
    s <- getLine
    k <- readLn
    putStrLn $ kth k s
