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