let () =
  let n, k = Scanf.scanf "%d %d\n" @@ fun a b -> a, b in
  let arr = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  let rec f x = if x = 1 then [] else x :: f arr.(x-1) in
  let l = f arr.(0) in
  let len = List.length l in
  let brr = Array.of_list l in
  print_int (brr.(k mod len)) 