#include using namespace std; typedef long long ll; typedef vector vint; typedef pair pint; typedef vector vpint; #define rep(i,n) for(int i=0;i<(n);i++) #define reps(i,f,n) for(int i=(f);i<(n);i++) #define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++) #define all(v) (v).begin(),(v).end() #define pb push_back #define mp make_pair #define fi first #define se second #define chmax(a, b) a = (((a)<(b)) ? (b) : (a)) #define chmin(a, b) a = (((a)>(b)) ? (b) : (a)) const int MOD = 1e9 + 7; const int INF = 1e9; ll d[200010]; int main(void){ int n; ll k; cin >> n >> k; ll wcnt = 0; rep(i, n){ cin >> d[i]; d[i]--; if(d[i] != i) wcnt++; } // printf("%lld\n", wcnt); ll good = 0; rep(i, n){ if(d[d[i]] == i && i != d[i]) good++; } // printf("%lld\n", good); ll sum = good / 2 + (wcnt - good) - 1; if((wcnt - good) == 0){ sum = good / 2; }else if((wcnt - good) % 2 == 1){ sum = good / 2 + (wcnt - good) - 1; }else{ sum = good / 2 + (wcnt - good); } ll nokori = k - sum; // printf("%lld %lld\n", sum, nokori); if(nokori < 0){ printf("NO\n"); }else if(nokori % 2 == 1){ printf("NO\n"); }else{ printf("YES\n"); } return 0; }