{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Data.List (inits, tails)
import qualified Data.Set  as S

main :: IO ()
main = do
  s <- getLine
  k <- readLn
  putStrLn $ solve s k

solve :: String -> Int -> String
solve s k = ts !! (k - 1) where
 ts = S.toList . S.fromList $ subLists k s

-- from submit #2530333
subLists :: Int -> [a] -> [[a]]
subLists k = concatMap (take k . tail . inits) . init . tails
