N,K = map(int,input().split()) L = list(map(int,input().split())) j = 0 for i,k in enumerate(L): if L[k - 1] == i + 1: j = j + 1 if k == i + 1: j = j + 1 j = j // 2 if K < N - 1 - j: print("NO") else: K = K - N + j if K % 2 == 0: print("YES") else: print("NO")