#include using namespace std; using ll = long long; ll N, K, D[200020]; bool used[200020]; int main() { cin.tie(0); ios_base::sync_with_stdio(false); cin >> N >> K; for(int i = 1; i <= N; ++i) cin >> D[i]; int ans = 0; for(int i = 1; i <= N; ++i) { if(!used[i] && i != D[i]) { used[i] = true; int pos = D[i]; while(pos != i) { used[pos] = true; pos = D[pos]; ++ans; } } } if(ans % 2 == K % 2) cout << "YES"; else cout << "NO"; cout << '\n'; return 0; }