import Control.Monad
import Data.List
import Data.Ord
import Debug.Trace

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

solve :: String -> Int -> String
solve s k = head . drop (k - 1) . debug . map head . group . sortBy cmpf . concat $ generate s

generate :: String -> [[String]]
generate (x : xs) = ([x] : map (x :) as) : as : bs
    where
        (as : bs) = generate xs
generate _ = [[]]

debug :: (Show a) => a -> a
debug x = trace (show x) x

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