import Control.Applicative
import Data.List

main = do
  s <- getLine
  k <- readLn
  putStrLn $ f s k

f s k = g (sort (init (tails s))) k

 
g (x:y:zs) k
  | lx >= k = take k x
  | ly - leh + lx >= k = take (leh + k - lx) y
  | leh == 0 = g (y:zs) (k-lx)
  | otherwise = ""
  where
    lx = length x
    ly = length y
    leh = eh x y
    ehs = take leh x

eh [] _ = 0
eh _ [] = 0
eh (x:xs) (y:ys) = if x == y then 1 + eh xs ys else 0