import Data.List

main = do
 s <- getLine
 x <- readLn 
 if length s == 1 then putStrLn s 
  else putStrLn ((nub (sort[ take len$ drop begin s|begin<-[0..length s -2],len<-[1..length s - begin]])) !!(x-1))