local ior = io.input() local n, k = ior:read("*n", "*n") local t = {} local searched = {} for i = 1, n do t[i] = ior:read("*n") searched[i] = false end local npos = 1 function getnext() for i = npos, n do if(not searched[i]) then npos = i + 1 return i end end return nil end local cur = getnext() local needcount = 0 while(cur ~= nil) do searched[cur] = true local epos = cur local len = 0 while(t[cur] ~= epos) do cur = t[cur] len = len + 1 searched[cur] = true end needcount = needcount + len cur = getnext() end if(k < needcount) then print("NO") else print((needcount - k) % 2 == 0 and "YES" or "NO") end