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(): return cnt == K if check(): print('YES') else: print('NO')