#include using namespace std; #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++) #define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--) #define all(a) (a.begin()),(a.end()) #define rall(a) (a.rbegin()),(a.rend()) #define fi first #define se second #define pb push_back #define eb emplace_back using ll = long long; using vll = vector; using vi = vector; using vvi = vector>; using P = pair; struct UnionFind { vector d; UnionFind(int N) : d(N, -1){} int root(int x) { if (d[x] < 0) return x; return d[x] = root(d[x]); } bool unite(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (d[x] > d[y]) swap(x, y); d[x] += d[y]; d[y] = x; return true; } bool same(int x, int y) { return root(x) == root(y); } int size(int x) { return -d[root(x)]; } }; void Main(){ ll n, k; cin >> n >> k; UnionFind UF(n); rep(i, n){ int d; cin >> d; d--; if(i != d){ UF.unite(i, d); } } set Root; rep(i, n){ int r = UF.root(i); Root.insert(r); } ll ans = n - Root.size(); if(k < ans || (k - ans) % 2) cout << "NO" << endl; else cout << "YES" << endl; return; } int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(15); Main(); return 0; }