local n, k = io.read("*n", "*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local map = {}
local len = 0
map[1] = 0
local src = 1
local rem = 0
while true do
  len = len + 1
  local dst = a[src]
  if len == k then
    print(dst)
    os.exit()
  end
  if map[dst] then
    local offset = map[dst]
    local loopSize = len - offset
    rem = k - offset
    rem = rem % loopSize
    src = dst
    break
  else
    map[dst] = len
  end
  src = dst
end
for i = 1, rem do
  local dst = a[src]
  src = dst
end
print(src)
