program main
  
  implicit none
  integer(16) :: n,k ,i, ans, now
  integer(16),allocatable :: a(:)
  
  read(*,*) n,k
  allocate(a(n))
  read(*,*) a
  
  now = 1
  do i = 1, n
    ans = a(now)
    now = ans
  end do
  do i = 1, mod(k,n)
    ans = a(now)
    now = ans
  end do
  
  print*, ans
  
  
end program main

