// yukicoder: No.482 あなたの名は // 2019.7.29 bal4u #include typedef long long ll; #if 1 #define gc() getchar_unlocked() #define pc(c) putchar_unlocked(c) #else #define gc() getchar() #define pc(c) putchar(c) #endif int in() { // 非負整数の入力 int n = 0, c = gc(); do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0'); return n; } ll In() { // 非負整数の入力 ll n = 0; int c = gc(); do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0'); return n; } void outs(char *s) { while (*s) pc(*s++); pc('\n'); } /* UNION-FIND library */ #define MAX 200003 int id[MAX], size[MAX]; void init(int n) { int i; for (i = 0; i < n; i++) id[i] = i, size[i] = 1; } int root(int i) { while (i != id[i]) id[i] = id[id[i]], i = id[i]; return i; } int connected(int p, int q) { return root(p) == root(q); } void unite(int p, int q) { int i = root(p), j = root(q); if (i == j) return; if (size[i] < size[j]) id[i] = j, size[j] += size[i]; else id[j] = i, size[i] += size[j]; } int N; ll K; int sz[MAX]; int main() { int i, ans; N = in(), K = In(), init(N+1); for (i = 1; i <= N; i++) unite(in(), i); for (i = 1; i <= N; i++) sz[root(i)]++; ans = 0; for (i = 1; i <= N; i++) if (sz[i] > 1) ans += sz[i]-1; outs(ans <= K && ((K - ans) & 1) == 0? "YES": "NO"); return 0; }