#include<bits/stdc++.h> using namespace std; typedef long long LL; struct cww{cww(){ ios::sync_with_stdio(false);cin.tie(0); cout<<fixed; cout<<setprecision(10); }}star; #define fin "\n" #define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++) #define REP(i,n) FOR(i,0,n) #define fi first #define se second #define pb push_back template <typename T>inline void chmin(T &l,T r){l=min(l,r);} template <typename T>inline void chmax(T &l,T r){l=max(l,r);} template <typename T> istream& operator>>(istream &is,vector<T> &v){ for(auto &it:v)is>>it; return is; } int main(){ LL N,K; cin>>N>>K; vector<LL> v(N); cin>>v; vector<int> used(N,0); LL f=0; REP(i,N)if(!used[i]){ used[i]=1; int sz=1; for(int u=v[i]-1;!used[u];u=v[u]-1) used[u]=1,sz++; if(sz>2)f=1; K-=sz-1; } if(K>=0&&K%2==0)cout<<"YES"<<endl; //else if(K>=0&&f)cout<<"YES"<<endl; else cout<<"NO"<<endl; return 0; }