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