#include<iostream>

using namespace std;
#define int long long

signed main(){

   int N, K;
   cin>> N>> K;
   int a[N];
   for(int i=0; i<N; i++){
      cin>> a[i];
      a[i]--;
   }

   int r=0;
   for(int i=0; i<N; i++){
      while(a[i]!=i){
         swap(a[i], a[a[i]]);
         r++;
      }
   }

   if(r>K){
      cout<< "NO"<< endl;
   }else if((K-r)%2){
      cout<< "NO"<< endl;
   }else{
      cout<< "YES"<< endl;
   }

   return 0;
}