let main () =
  let s, k = Scanf.scanf "%s\n%d\n" (fun a b -> a, b) in
  let xs = ref BatSet.empty in
  for i = 0 to String.length s - 1 do
    for j = 1 to String.length s - i do
      xs := BatSet.add (String.sub s i j) !xs
    done;
  done;
  let ys = ref @@ BatSet.to_list !xs in
  ys := List.sort String.compare !ys;
  Printf.printf "%s\n" (List.nth !ys (k-1))

let _ = main ()
