import Data.List
import Data.Ord
import Data.Function 
import qualified Data.Set as S

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

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

newtype S = S { dat :: String }
    deriving (Eq)

wrap :: String -> S 
wrap = S 

instance Ord S where
    compare = cmp `on` dat

cmp :: String -> String -> Ordering
cmp (x : xs) (y : ys) = compare x y `mappend` cmp xs ys
cmp (_ : _) _ = GT
cmp _ (_ : _) = LT
cmp _ _ = EQ