program main
  implicit none
  integer(8) :: N,K
  integer(8),allocatable :: A(:)
  integer(8),allocatable :: num(:)
  logical,allocatable :: flag(:)
  integer(8) :: loopnum
  integer :: now
  integer(8) :: step
  integer(8) :: i,j
  
  read(*,*) N,K
  allocate(A(N))
  read(*,*) A(:)
  allocate(flag(N))
  allocate(num(N))
  flag(:) = .false.
  flag(1) = .true.
  num(1) = int(0)
  now = 1
  now = A(int(now))
  do i = 1,N
     if ( flag(int(now)) ) then
        exit
     else 
        flag(int(now)) = .true.
        num(int(now)) = i
        now = A(int(now))
     end if
  end do
  ! loop num
  loopnum = i - num(int(now))
  !write(*,*) loopnum
  step = mod( K-num(int(now)), loopnum )
  do i = 1,step
     num(int(now)) = i
     now = A(int(now))
  end do
  write(*,'(i0)') now
end program main
