import           Data.List (group, sort)

main :: IO ()
main = do
  s <- getLine
  k <- read <$> getLine :: IO Int
  putStrLn $ solve k s

solve :: Int -> String -> String
solve n s = let ss = map head . group . sort $ f s
            in ss !! (n - 1)
  where
    f = foldr (++) [] . scanr (\a b -> [a] : map (a:) b) []
