#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() template inline bool chmax(A &a, B b) { if (a inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; } typedef unsigned long long ull; typedef long long ll; typedef pair pii; typedef pair pll; typedef pair P; const ll INF = 1ll<<29; const ll MOD = 1000000007; const double EPS = 1e-12; ll n, k; int d[212345]; bool done[212345]; int main() { cin >> n >> k; REP(i, n) { scanf("%d", d + i); d[i]--; } int cnt = 0; REP(i, n) { if (done[i]) continue; done[i] = true; int c = 1, now = d[i]; while (!done[now]) { done[now] = true; now = d[now]; c++; } cnt += c - 1; } bool ok = true; if (cnt > k) ok = false; if ((k - cnt) % 2 == 1) ok = false; puts(ok ? "YES" : "NO"); return 0; }