#include using namespace std; using ll = long long; #define FOR(i, a, b) for (int i = (a); i < int(b); ++i) #define RFOR(i, a, b) for (int i = (b) - 1; i >= int(a); --i) #define rep(i, n) FOR(i, 0, n) #define rep1(i, n) FOR(i, 1, int(n) + 1) #define rrep(i, n) RFOR(i, 0, n) #define rrep1(i, n) RFOR(i, 1, int(n) + 1) #define all(c) begin(c), end(c) template void __dump__(const T &first){ std::cerr << first << std::endl; } template void __dump__(const First& first, const Rest&... rest) { std::cerr << first << ", "; __dump__(rest...); } #define dump(...) { std::cerr << __LINE__ << ":\t" #__VA_ARGS__ " = "; __dump__(__VA_ARGS__); } struct uf_tree { std::vector parent; int __size; uf_tree(int size_) : parent(size_, -1), __size(size_) {} void unite(int x, int y) { if ((x = find(x)) != (y = find(y))) { if (parent[y] < parent[x]) std::swap(x, y); parent[x] += parent[y]; parent[y] = x; __size--; } } bool is_same(int x, int y) { return find(x) == find(y); } int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); } int size(int x) { return -parent[find(x)]; } int size() { return __size; } }; int a[200010]; int main(){ int n, k; while(cin >> n >> k){ uf_tree uf(n); rep(i, n){ cin >> a[i]; --a[i]; uf.unite(i, a[i]); } map cnt; rep(i, n){ int r = uf.find(i); ++cnt[uf.size(r)]; } int sw = 0; for(auto &x : cnt){ int g = x.second / x.first; int k = g * (x.first - 1); // dump(x.first, x.second, k); sw += k; } if(sw > k){ puts("NO"); } else { puts((k - sw) % 2 == 0 ? "YES" : "NO"); } } }