import Data.List

// 部分文字列をまともに求めると爆発するのでn文字で足きり
// n+1文字の文字列から先頭から1,..,n文字までの部分文字列が辞書順で前に来る
substrings :: Int -> String -> [String]
substrings _ "" = []
substrings 0 _ = []
substrings n s@(_:r) = (substrings' n s) ++ (substrings (n - 1) r)
    where
        substrings' _ "" = []
        substrings' 0 _ = []
        substrings' n (c:r) = [c:""] ++ (map ((:)c) $ substrings' (n - 1) 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 k s) !! (k - 1)
    where
        f e r = pickup_small k (e:r)

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