N,K = map(int,input().split()) L = list(map(int,input().split())) def min_gokan(A): B = [[]] i = 0 A2 = A[:] while A2: a = A2[0] while B[i] == [] or a != B[i][0]: B[i].append(a) A2.remove(a) a = A[a - 1] i = i + 1 B.append([]) B.pop() r = len(A) - len(B) return r m = min_gokan(L) if m > K: print("NO") elif (K - m) % 2 == 0: print("YES") else: print("NO")