program free
	implicit none
	integer :: i, count=0
	integer(8):: n,k,ans,loop,machi=1
	integer(8),allocatable :: a(:),trace(:)
	read (*,*) n,k
	allocate(a(n))
	allocate(trace(n+1))
	do i=1,n+1
    	trace(i)=0
    end do
	read (*,*) a
	do i=1,n
		count=count+1
		if(trace(machi)/=0) exit
		trace(machi)=i
		machi=a(machi)
	end do
	if(count==2) then
		write (*,'(i0)') 1
	else
		loop=count-trace(machi)
		ans=mod(k-trace(machi)+1,loop)
		do i=1,ans
			machi=a(machi)
		end do
		write (*,'(i0)') machi
	end if
	end program free