long k;n,t,d[1<<18],u[1<<18];main(i){for(scanf("%d%d",&n,&k);~scanf("%d",d+i++););for(i--;--i;)for(k+=!u[t=i];!u[t];t=d[u[t]=t])k--;n=!puts(k<0||k&1?"NO":"YES");}