program main
  
  implicit none
  integer(16) :: n, k, i, now, cyc,tmp, num
  integer(16),allocatable :: a(:), b(:), bo(:), cnt(:)
  
  read(*,*) n,k
  allocate(a(n))
  allocate(b(n))
  allocate(bo(n))
  allocate(cnt(n))
  read(*,*) a
  
  ! initialize  
  b  = 0
  bo = 0
  cyc = 0
  cnt = 0
  num = 0

  now = 1
  b(now) = 0
  bo(now) = 0
  cnt(now) = 1

  do i = 1, k+1
    cnt(a(now)) = cnt(a(now)) + 1
    if( cnt(a(now)) == 2 )then
      cyc = i - bo(a(now))
      num = 1
      exit
    end if
    now = a(now)
    b(now) = i
    bo(now) = b(now)
  end do
  !print*, cyc, now, b(now), bo(a(now)), bo(now), k

  if( num == 1 ) then
    !print*, mod(k-b(now),cyc)
    do i = 1, mod(k-b(now),cyc)
      now = a(now)
    end do
  end if
  
  print*, now
  
  
end program main

