import Data.List

main = do
    s <- getLine
    k <- readLn
    let n = length s
    putStrLn . head . (!! (k-1)) . group $ sort [take (j-i+1) (drop (i-1) s) | i <- [1..n], j <- [i..(min n (i+k-1))]]