#include #include #include using namespace std; #define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++) #define rep(i,n) FOR((i),0,(n)) typedef long long ll; const int INF=1e9+7; const int MAX_N=2*1e5+5; int a[MAX_N]; bool used[MAX_N]; int dep(int now,int from){ used[now]=true; if(now==from)return 1; return dep(a[now],from)+1; } int main(){ fill(used,used+MAX_N,false); ll n,k; cin>>n>>k; ll ans=0; rep(i,n){ int x; cin>>x; if(x!=i+1)ans++; a[i+1]=x; } int max_d=0; rep(i,n){ if(!used[i])max_d=max(max_d,dep(a[i],i)); } ans=ans/2+(ans%2); if(k=3)cout<<"YES"<=0)cout<<"YES"<=0)cout<<"YES"<