program free
	implicit none
	integer(8):: n,k,ans,loop,machi=1,count=0,i
	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,k
		count=count+1
		if(trace(machi)/=0) exit
		trace(machi)=i
		machi=a(machi)
	end do
	if(count==2) then
		write (*,'(i0)') 1
	else if(count==k) then
		write (*,'(i0)') machi
	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