N,K=map(int,input().split()) D=[ x-1 for x in map(int,input().split())] x=0 for i in range(N): if D[i]==i:continue j=D[i] D[i]=D[j] D[j]=j x+=1 print(('NO','YES')[K>=x and (K-x)%2==0])