import qualified Data.Set as Set

substrings :: String -> [String]
substrings s = let (xs, ys) = makeSubstrings s in (xs ++ ys)
  where
    makeSubstrings :: String -> ([String], [String])
    makeSubstrings "" = ([],[])
    makeSubstrings (c:cs) = let (xs, ys) = makeSubstrings cs
                            in ([c] : map (c:) xs, xs ++ ys)

main :: IO ()
main = do
  s <- getLine
  k <- read <$> getLine
  putStrLn $ (!! (k-1)) $ Set.toList $ Set.fromList $ substrings s
