program ABC167_D
  integer(8)::N,K,X,Y,Z
  integer(8),allocatable::A(:),S(:),T(:)
  read(*,*)N,K
  allocate(A(N),S(N),T(N))
  read(*,*)A
  M=1
  L=1
  S=0
  T=0
  T(1)=1
  S(1)=1
  do i=1,N
     M=A(M)
     S(M)=S(M)+1
     if(S(M)==2) then
        do j=1,N
           if(L==M) then
              X=i-j+1
              Y=i
              Z=j
              go to 10
           end if
           L=A(L)
        end do
     end if
  end do
10 if(K>N) then
      K=mod(K-Z+1,X)+Z-1
      end if
      
      
  M=1
  do i=1,K
     M=A(M)
  end do
  write(*,*)M
end program ABC167_D