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

import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
import qualified Data.Set as S

sol :: Int -> B.ByteString -> Char -> B.ByteString
sol n s c =
    if sz < n
        then sol (n-sz) s (succ c)
        else S.elemAt (n-1) sets
    where
        sz = S.size sets
        sets = V.foldl' (\set st -> S.insert st set) S.empty ss
        ss = V.concatMap ps $ V.unfoldr fi (0,s)
        fi (o,st) = case B.findIndex (==c) st of
            (Just i) -> Just(o+i, (o+i+1, B.drop (i+1) st))
            Nothing  -> Nothing 
        ps i = V.unfoldr vsnoc $ B.drop i s
        vsnoc bs
            | B.length bs == 0 = Nothing
            | otherwise        = Just (bs, B.init bs)

main = do
    s <- B.getLine
    n <- readLn
    putStrLn $ B.unpack $ sol n s 'a'
