N,K = map(int,input().split()) lst = [0]+list(map(int,input().split())) cnt = 0 def change(i,x): global cnt lst[i] = lst[x] lst[x] = x cnt+=1 if i!=lst[i]: change(i,lst[i]) for i in range(N+1): x = lst[i] if x!=i: change(i,x) print("NO" if cnt>K or (K-cnt)%2 else "YES")