let () =
  let s = Scanf.scanf "%s " (fun a -> a) in
  let k = Scanf.scanf "%d " (fun a -> a) in

  let length = String.length s in

  let rec f str fst fnl res = 
    if fst = length then res else (
      let res = (String.sub str fst fnl) :: res in
      if (fst + fnl = length || fnl = k) then
        f str (fst+1) 1 res
      else
        f str fst (fnl+1) res
    )

  in
  let lst = f s 0 1 [] in
  let lst = List.sort_uniq compare lst in

  print_endline (List.nth lst (k-1))

