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

D={[0]=A}
for i=1,math.log(K)/math.log(2) do
	D[i]={}
	for j=1,N do
		D[i][j]=D[i-1][D[i-1][j]]
	end
end

local a=1
for i=0,math.log(K)/math.log(2)do
	if((K>>i)&1~=0)then
		a=D[i][a]
	end
end
print(a)