let s = read_line ()
let k = Scanf.sscanf (read_line ()) "%d" @@ fun k -> k

let s_len = String.length s

let () =
  let acc = 
    List.init s_len (fun i -> List.init (min 5 (s_len - i)) (fun j -> String.sub s i (j + 1)))
    |> List.flatten 
    |> List.sort_uniq compare in
  print_endline @@ List.nth acc (k - 1)
  