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 k do
      xs := BatSet.add (String.sub s i j) !xs
    done;
  done;
  let ys = BatSet.to_array !xs in
  Array.sort String.compare ys;
  Printf.printf "%s\n" (ys.(k-1))

let _ = main ()
