al=[[x]|x<-['a'..'z']]
main=do
 s<-getLine;k<-readLn
 putStrLn(f s k al (length s))
  where f s k (q:t) n =if(substr s n q (length q))then(if k==1 then q else(f s (k-1) (add q t) n))else(f s k t n)
        substr s n q m =if n<m then False else(if(take m s)==q then True else(substr(tail s)(n-1)q m))
        add q t =((map (\x->q++x))al)++t