import qualified Data.ByteString.Char8 as B
import qualified Data.Set              as S

main :: IO ()
main = B.putStrLn =<< solve <$> B.getLine <*> readLn

solve :: B.ByteString -> Int -> B.ByteString
solve s k = S.elemAt k $ S.fromList $ substrings s

substrings :: B.ByteString -> [B.ByteString]
substrings = concat . map B.tails . B.inits