#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define mt make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; int main(){ ios::sync_with_stdio(false); cin.tie(0); ll N, K; while(cin >> N >> K) { vi D(N); rep(i, N)cin >> D[i], --D[i]; vi vis(N); int need = 0; rep(i, N)if(!vis[i]) { int x = i, y = 0; do { y++; vis[x] = 1; x = D[x]; } while(x != i); need += y - 1; } K -= need; string ans = "YES"; if(K < 0 || K % 2)ans = "NO"; cout << ans << endl; } }