#include using namespace std; #define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++) #define ALL(x) x.begin(),x.end() template bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; } template bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; } typedef long long ll; ll N,K; vector A; bool vis [200001]; ll dfs(int curr) { vis [curr] = true; if(vis [A [curr]]) return 1; return dfs(A [curr]) + 1; } int main() { scanf("%lld%lld",&N,&K); A.assign(N + 1,0); FOR(i,1,N + 1){ scanf("%d",&A [i]); } ll t = 0; FOR(i,1,N + 1) if(vis [i] == false){ t += dfs(i) - 1; } if(t <= K && (K - t) % 2 == 0){ printf("YES\n"); } else{ printf("NO\n"); } return 0; }