N,K = map(int,input().split()) L = list(map(int,input().split())) def min_gokan(A): count = 0 for i in range(len(A)): while A[i] - 1 != i: A[A[i] - 1],A[i] = A[i],A[A[i] - 1] print(i,A[i]) count = count + 1 print("c",count) return count m = min_gokan(L) if m > K: print("NO") elif (K - m) % 2 == 0: print("YES") else: print("NO")