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 i len =
    if x = 1 || i = len then [] else x :: f arr.(x-1) (i+1) len in
  let brr = Array.of_list (f arr.(0) 1 (Array.length arr)) in
  let len = Array.length brr in
  print_int (brr.(k mod len)) 