{-# OPTIONS_GHC -O #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Data.List

snub [x] = [x]
snub (x:y:rs)
    | (x == y)  = snub (y:rs)
    | otherwise = x : snub (y:rs)

ss xs = map (\c -> (findIndices (==c) xs)) ['a'..'z']

ss2 x [] = []
ss2 x is = snub $ sort $ concatMap (\i -> subs $ drop i x) is

subs [] = []
subs xa@(x:xs) = (drop 1 $ inits xa) ++ (subs xs)

ss3 :: Int -> String -> [[Int]] -> String
ss3 n x [] = []
ss3 n x (is:iss)
    | ((length sub) >= n) = head $ drop (n-1) sub
    | otherwise           = ss3 (n - (length sub)) x iss
        where sub = ss2 x is

main = do
    s <- getLine
    n <- readLn
    putStrLn $ ss3 n s $ ss s
