#include #include #include #define SIZE 30 using std::vector; using std::cin; using std::cout; using std::endl; using std::sort; int main() { std::cin.tie(0);std::ios::sync_with_stdio(false); int64_t n; int64_t k; int d[200001] = {}; int b[200001] = {}; cin >> n; cin >> k; int64_t inp; int64_t count=0; for(int i=1;i<=n;++i){ cin>>d[i]; } for(int i=1;i<=n;++i){ if(b[i]==0){ b[i]=1; int j = i; while(d[j]!=i){ j = d[j]; count++; b[j]=1; } } } if(count > k || count%2 != k%2){ cout << "NO"; }else{ cout << "YES"; } return 0; }