import sys input = sys.stdin.readline N,K=map(int,input().split()) D=list(map(int,input().split())) for i in range(N): D[i]-=1 # UnionFind Group = [i for i in range(N)] # グループ分け Nodes = [1]*(N) # 各グループのノードの数 def find(x): while Group[x] != x: x=Group[x] return x def Union(x,y): if find(x) != find(y): if Nodes[find(x)] < Nodes[find(y)]: Nodes[find(y)] += Nodes[find(x)] Nodes[find(x)] = 0 Group[find(x)] = find(y) else: Nodes[find(x)] += Nodes[find(y)] Nodes[find(y)] = 0 Group[find(y)] = find(x) for i in range(N): Union(i,D[i]) X=[] for i in range(N): if find(i)==i: X.append(Nodes[i]) ANS=0 for x in X: ANS+=x-1 if ANS<=K and ANS%2==K%2: print("YES") else: print("NO")