#include #include using namespace std; int main(){ int N; long long K; cin >> N >> K; vector D(N); for (int i = 0; i < N; i++){ cin >> D[i]; D[i]--; } int M = 0; vector used(N, false); for (int i = 0; i < N; i++){ if (!used[i]){ used[i] = true; int cnt = 1; int p = i; while (!used[D[p]]){ used[D[p]] = true; cnt++; p = D[p]; } M += cnt - 1; } } if (M >= K && M % 2 == K % 2){ cout << "YES" << endl; } else { cout << "NO" << endl; } }