{-# LANGUAGE OverloadedStrings, ViewPatterns #-}
import Data.List
import Data.Ord
import Data.Function 
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B 

main :: IO ()
main = B.getLine >>= main'
    where
        main' s = readLn >>= B.putStrLn . solve s 

-- |
-- >>> B.unpack $ solve (B.pack "aba") 4
-- "b"
-- >>> B.unpack $ solve (B.pack "atcoderandatcodeer") 5
-- "andat"
-- >>> B.unpack $ solve (B.pack "z") 1
-- "z"
solve :: B.ByteString -> Int -> B.ByteString 
solve ss k = dat . head . drop (k - 1) . S.toAscList $ generate S.empty ss
    where
        generate acc xxs@(B.uncons -> Just (_, xs)) = generate acc' xs
            where
                acc' = foldl' (flip S.insert) acc ys
                ys = map wrap . tail . B.inits $ B.take k xxs
        generate acc _ = acc 

newtype S = S { dat :: B.ByteString }
    deriving (Eq)

wrap :: B.ByteString -> S 
wrap = S 

instance Ord S where
    compare = cmp `on` dat

cmp :: B.ByteString -> B.ByteString -> Ordering
cmp (B.uncons -> Just (x, xs)) (B.uncons -> Just (y, ys)) = compare x y `mappend` cmp xs ys
cmp (B.uncons -> Just _) _ = GT
cmp _ (B.uncons -> Just _) = LT
cmp _ _ = EQ