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 $ substrings s

substrings :: B.ByteString -> S.Set B.ByteString
substrings = S.unions . map (S.fromList . B.tails) . B.inits