//
// Created by yamunaku on 2019/07/14.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

class UnionFind{
    vi node;
public:
    UnionFind(int n){
        node=vi(n,-1);
    }
    int root(int x){
        if(node[x]<0) return x;
        return node[x]=root(node[x]);
    }
    bool uni(int x, int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(-node[x]<-node[y]) swap(x,y);
        node[x]+=node[y];
        node[y]=x;
        return true;
    }
};

int main(){
    int n,r;
    cin >> n >> r;
    vi p(n);
    UnionFind uf(n);
    rep(i,n){
        cin >> p[i];
        p[i]--;
        uf.uni(i,p[i]);
    }
    vi c(n);
    rep(i,n){
        c[uf.root(i)]++;
    }
    vi v;
    v.reserve(n);
    rep(i,n){
        if(c[i]>0) v.push_back(c[i]);
    }
    n=v.size();
//    sort(all(v));
    rep(i,n){
        if(v[i]==r){
            CYES;
            return 0;
        }
    }
    random_device seed_gen;
    mt19937 engine(seed_gen());
    int q=1e8/n;
    rep(_,q){
        shuffle(all(v), engine);
        int k=0,idx=0;
        while(k<r){
            k+=v[idx];
            idx++;
        }
        if(k==r){
            CYES;
            return 0;
        }
    }
    CNO;
    return 0;
}



### Prompt

Construct a Cpp code solution to the problem outlined:

D: Two Colors Sort

problem

During the walk, umg found a sequence of length N, P_1, P_2, ..., P_N, which can be made by rearranging 1,2, ..., N.

umg can use mysterious powers to exchange places by choosing two different numbers painted in the same color.

umg wanted to be able to sort the sequence in ascending order by painting R of the numbers in the sequence in red and the remaining N-R in blue.

umg Determine if you can reach your goal.

However, the numbers are so heavy that they cannot be moved without mysterious force. Also, since umg is a genius, you can use mysterious powers any number of times.

Input format


N R
P_1 P_2 ... P_N


Constraint

* 1 \ leq N \ leq 3 \ times 10 ^ 5
* 1 \ leq R \ leq N
* 1 \ leq P_i \ leq N
* P_i \ neq P_j (1 \ leq i <j \ leq N)
* All inputs are integers.



Output format

umg Print `Yes` if you can achieve your goal, otherwise` No` on one line.

Input example 1


3 2
1 3 2


Output example 1


Yes

* You can achieve your goal by painting 1 in blue and 2 and 3 in red.



Input example 2


5 2
1 2 3 4 5


Output example 2


Yes

* They are arranged in ascending order from the beginning.



Input example 3


10 7
3 4 8 5 7 6 2 10 1 9


Output example 3


No





Example

Input

3 2
1 3 2


Output

Yes

### Response

```cpp
//
// Created by yamunaku on 2019/07/14.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

class UnionFind{
    vi node;
public:
    UnionFind(int n){
        node=vi(n,-1);
    }
    int root(int x){
        if(node[x]<0) return x;
        return node[x]=root(node[x]);
    }
    bool uni(int x, int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(-node[x]<-node[y]) swap(x,y);
        node[x]+=node[y];
        node[y]=x;
        return true;
    }
};

int main(){
    int n,r;
    cin >> n >> r;
    vi p(n);
    UnionFind uf(n);
    rep(i,n){
        cin >> p[i];
        p[i]--;
        uf.uni(i,p[i]);
    }
    vi c(n);
    rep(i,n){
        c[uf.root(i)]++;
    }
    vi v;
    v.reserve(n);
    rep(i,n){
        if(c[i]>0) v.push_back(c[i]);
    }
    n=v.size();
//    sort(all(v));
    rep(i,n){
        if(v[i]==r){
            CYES;
            return 0;
        }
    }
    random_device seed_gen;
    mt19937 engine(seed_gen());
    int q=1e8/n;
    rep(_,q){
        shuffle(all(v), engine);
        int k=0,idx=0;
        while(k<r){
            k+=v[idx];
            idx++;
        }
        if(k==r){
            CYES;
            return 0;
        }
    }
    CNO;
    return 0;
}



```