N,K = map(int,input().split()) D = list(map(int,input().split())) cnt = 0 for i in range(N): if D[i] != i+1: a,b = D[i]-1,D[D[i]-1]-1 D[a],D[b] = D[b],D[a] cnt+=1 def check(): if K < cnt: return False return (K - cnt) % 2 == 0 if check(): print('YES') else: print('NO')