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] count = count + 1 return count m = min_gokan(L) if m > K: print("NO") elif (K - m) % 2 == 0: print("YES") else: print("NO")