import Data.List (foldl')
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B

solve :: B.ByteString -> Int -> B.ByteString
solve s k = S.toAscList go !! (k-1) where
  go = foldl' go' S.empty [1..k]
  go' arg p = foldl' go'' arg [0..max (B.length s - p) 0] where
    go'' substrs i
      | S.size substrs < k || sub < (S.toAscList substrs) !! (k-1) = S.insert sub substrs
      | otherwise = substrs
      where
        sub = B.take p $ B.drop i s

main = do
  s <- B.getLine
  k <- (fst . (\(Just x) -> x) . B.readInt) <$> B.getLine
  B.putStrLn $ solve s k

