#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ALL(a) (a).begin(), (a).end() using ll = long long; using P = pair; struct State { int v, cost; State(int v, int cost): v(v), cost(cost) {} // 昇順 bool operator<(const State& s) const { return cost < s.cost; } // 降順 bool operator>(const State& s) const { return cost > s.cost; } }; void dump_vector(vector vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << (i < vec.size() - 1 ? " " : "\n"); } } int main() { int n; ll k; cin >> n >> k; int diff_cnt = 0; vector d(n); for (int i = 0; i < n; i++) { cin >> d[i]; d[i]--; if (i != d[i]) diff_cnt++; } // 2でswapできるだけswap // 3でつじつま合わせ ll swap2 = (diff_cnt + 1) / 2; if (swap2 > k) { cout << "NO" << endl; } else if ((k - swap2) % 2 == 0) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }