def f(s): return int(s)-1 N,K=map(int,input().split()) D=list(map(f,input().split())) U=set() L=[] for i in range(N): if i not in U: U.add(i) M=[i] x=i while True: x=D[x] if x!=i: U.add(x) M.append(x) else: L.append(M) break S=0 for H in L: S+=len(H)-1 if S<=K and (K-S)%2==0: print("YES") else: print("NO")