N=io.read"*n"
K=io.read"*n"
A={}
for i=1,N do
	A[i]=io.read"*n"
end

local function count(t)local r=0 for _,_ in pairs(t)do r=r+1 end return r end

B={[1]=0}
C={[0]=1}
for i=1,math.min(N,K) do
	C[i]=A[C[i-1]]
	if(B[C[i]])then
		t=C[i]
		for j=i-1,1,-1 do
			if(C[j]==t)then
				print(C[j+(K-j)%(i-j)])
				return
			end
		end
	end
	B[C[i]]=0
end
print(C[K])