let () =
  Scanf.scanf "%d %d" @@ fun n k ->
  let a = Array.init (n+1) (fun i -> if i = 0 then 1 else Scanf.scanf " %d" Fun.id) in

  let lv = Array.make (n+1) (-1) in
  let rec loop c i =
    if c = k then i
    else if lv.(i) >= 0 then
      let c' = lv.(i) in
      if (k - c) mod (c - c') = 0 then i
      else loop (c+1) a.(i)
    else begin
      lv.(i) <- c;
      loop (c+1) a.(i)
    end in

  Printf.printf "%d\n" (loop 0 1)