#pragma GCC optimize("Ofast") #include using namespace std; #define rep(i, n) for(int i = 0; i < (int)(n); ++i) #define all(x) x.begin(),x.end() #define ln '\n' const long long MOD = 1000000007LL; //const long long MOD = 998244353LL; typedef long long ll; typedef unsigned long long ull; typedef pair pii; typedef pair pll; template inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; } template inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; } /////////////////////////////////////////////////////////////////////////////////////////////////// int A[202020]; bool check[202020]; int dfs(int v) { if (check[v]) return -1; check[v] = 1; return 1 + dfs(A[v]); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll N,K; cin >> N >> K; rep(i,N) { cin >> A[i]; --A[i]; } int cnt = 0; rep(i,N) { if (check[i]) continue; cnt += dfs(i); } if (cnt <= K && (K-cnt)%2==0) cout << "YES" << ln; else cout << "NO" << ln; }