module CharMap = Map.Make (Char)

let () =
  let s = read_line () in
  Array.init (String.length s) (fun i -> i, s.[i])
  |> Array.fold_left (fun m (i, c) ->
      CharMap.add c (i :: try CharMap.find c m with Not_found -> []) m) CharMap.empty
  |> CharMap.bindings
  |> List.map (fun (_, is) ->
      List.map (fun i ->
        Array.init 5 (fun n ->
          try [String.init (n + 1) (fun j -> s.[i + j])]
          with _ -> [])
        |> Array.to_list
        |> List.concat) is |> List.concat)
  |> List.concat
  |> List.sort_uniq compare
  |> Scanf.scanf "%d\n" (fun k l -> List.nth l (k - 1))
  |> print_endline