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

import Control.Monad
import Data.List
import qualified Data.Set as S

sol :: Int -> String -> Char -> String
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 = foldl' (\set s -> S.insert s set) S.empty ss
        ss = concatMap ps $ findIndices (==c) s
        ps i = drop 1 $ inits $ drop i s

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