
local n = io.read("*n")
local k = io.read("*n")
local tbA = {}
for i = 1,n do
    table.insert(tbA,io.read("*n"))
end
io.read()

function isNumInTb(num,tb)
    for k,v in ipairs(tb) do
        if v == num then
            return k
        end
    end
    return 0
end

-- function print_tb(tb)
--     for k,v in ipairs(tb) do
--         print(v.." ")
--     end
-- end

local new_tb = {}
local new_new_tb = {}
local idx = 0

local i = 1
while tbA[i] do
    if isNumInTb(i,new_tb) > 0 then
        
        local j = isNumInTb(i,new_tb)
        idx = isNumInTb(i,new_tb)
        for m=idx,#new_tb do
            table.insert(new_new_tb,new_tb[m])
            j = j + 1
        end
        break
    else
        table.insert(new_tb,i)
        i = tbA[i]
    end
end
k = k - idx + 1
local numTb = #new_new_tb

local kk = math.mod(k,numTb)
if kk==0 then kk = kk + numTb end
print(tbA[new_new_tb[kk]])

-- for i = 1, string.len(a) do
--     table.insert(b,string.sub(a,i,i))
-- end
