#include main(){ int N,K; int D[200000]; scanf("%d%d",&N,&K); for(int i = 0;i < N;i++){ scanf("%d",&D[i]); } int count = 0,scnt = 0; for(int i = 0;i < N;i++){ if(D[i]==i+1)continue; count++; if(D[D[i]-1]==i+1)scnt++; } count -= scnt/2; if(count > K){ printf("NO\n"); return 0; } printf("%s\n",(K-count)%2?"NO":"YES"); }