#include<bits/stdc++.h>
using namespace std;
using ll = long long;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

struct UnionFind{
    vector<ll> parent;
    UnionFind(ll sz){
        parent.resize(sz);
        reset();
    }

    void reset(){
        FOR(i, 0, parent.size()){
            parent[i] = i;
        }
    }

    void unite(ll a, ll b){
        if(a>b){
            swap(a, b);
        }
        // cout << "unite " << a << " " << b << endl;
        ll rootA = findRoot(a);
        ll rootB = findRoot(b);
        if(rootA>rootB){
            swap(rootA, rootB);
        }
        if(rootA==rootB){
            return;
        }else{
            // 小さい方を親にする
            parent[rootB] = rootA;
        }
    }

    ll findRoot(ll a){
        if(parent[a]==a){
            return a;
        }else{
            return parent[a] = findRoot(parent[a]);
        }
    }

    map<ll, vector<ll> > getGroups(){
        map<ll, vector<ll> > G;
        FOR(i, 0, parent.size()){
            ll r = findRoot(i);
            G[r].push_back(i);
        }
        return G;
    }

    bool is_same_group(ll a, ll b){
        ll rootA = findRoot(a);
        ll rootB = findRoot(b);
        if(rootA==rootB){
            return true;
        }else{
            return false;
        }
    }
};

const ll MAX_V = 300010;
bool dp[MAX_V];

// ant book p64
// a : value
// m : count
// K : target number
bool can_make(vector<ll>& a, vector<ll>& m, ll K){
    FOR(i, 0, MAX_V){
        dp[i] = -1;
    }    
    ll N = a.size();
    FOR(i, 0, N){
        FOR(j, 0, K+1){
            if(dp[j]>=0){
                dp[j]=m[i];
            }else if(j<a[i] || dp[j-a[i]]<=0){
                dp[j] = -1;
            }else{
                dp[j]=dp[j-a[i]] - 1;
            }
        }
    }
    if(dp[K]>=0){ 
        return true;
    }else{
        return false;
    }
}

bool can_make_naive(vector<ll>& a, vector<ll>& m, ll K){
    vector<ll> V;
    FOR(i, 0, a.size()){
        FOR(j, 0, m[i]){
            V.push_back(a[i]);
        }
    }
    ll N = V.size();

    // p("V");
    // vprint(V);

    FOR(i, 0, 1<<N){
        ll sum = 0;
        FOR(j, 0, N){
            if(i>>j&1){
                sum += V[j];
            }
        }
        if(sum==K) return true;
    }
    return false;
}

bool can_make_bitset_ver(vector<ll>& a, vector<ll>& m, ll K){
    vector<ll> V;
    FOR(i, 0, a.size()){
        FOR(j, 0, m[i]){
            V.push_back(a[i]);
        }
    }
    ll N = V.size();
    bitset<150001> dp;
    dp[0] = 1;
    for(int a : V) dp |= (dp << a);
    if(dp[K]){
        return true;
    }else{
        return false;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input
    ll N, R;
    cin >> N >> R;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
        A[i]--;
    }

    auto uf = UnionFind(N);

    FOR(i, 0, N){
        uf.unite(i, A[i]);
    }

    auto group_mp = uf.getGroups();
    map<ll, ll> mp;
    for(auto pa : group_mp){
        ll sz = pa.second.size();
        mp[sz]++;
    }
    
    vector<ll> V; // value
    vector<ll> C; // count
    for(auto pa : mp){
        ll v = pa.first;
        ll c = pa.second;
        V.push_back(v);
        C.push_back(c);
    }
    // vprint(V);
    // vprint(C);

    // if(can_make_naive(V, C, R)){
    if(can_make_bitset_ver(V, C, min(N-R, R))){
    // if(can_make(V, C, R)){
        p_yes();
    }else{
        p_no();
    }

    return 0;
}


Measured memory_bytes: 44500