program teleporter
  implicit none
  integer :: n, a(200000) = 0, i, v = 1
  integer(8) :: k, cnt(200000) = -1_8, c = 0_8
  read(*,*) n, k
  read(*,*) a(1:n)
  do
    if (cnt(v) >= 0_8) exit
    cnt(v) = c
    v = a(v)
    c = c+1_8
    if (c == k) then
      write(*,'(i0)') v
      stop
    end if
  end do
  k = mod(k-cnt(v),c-cnt(v))
  do i = 1, n
    if (cnt(i)-cnt(v) == k) then
      write(*,'(i0)') i
      stop
    end if
  end do
end program teleporter