#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;

#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};




struct UnionFind{
  int n,num;
  vector<int> r,p;
  UnionFind(){}
  UnionFind(int sz):n(sz),num(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
    num--;
  }
  int size(int x){
    return r[find(x)];
  }
  int hoge(int x){
  	return find(x);
  }
  int count() const{
    return num;
  }
};


signed main(){
	int n,r;
	cin>>n>>r;
	vector<int> v;
	map<int,int> m;
	lp(i,n){
		int a;
		cin>>a;
		v.push_back(a);
		m[a]=i;
	}
	sort(v.begin(),v.end());
	UnionFind UF(n);
	lp(i,v.size()){
		UF.unite(i,m[v[i]]);
	}
	//cout<<UF.count()<<endl;
	vector<int> s;
	set<int> h;
	lp(i,n){
		if(h.find(UF.hoge(i))==h.end()){
			h.insert(UF.hoge(i));
			s.push_back(UF.size(i));
		}
	}
	
    sort(s.begin(),s.end());
	int mm = s.size();

    /*
    for(int i = 0; i < mm; i++){
        cerr << s[i] << " ";
    }
    cerr << endl;
    */
    vector<int> acc(mm + 1, 0);
    for(int i = 0; i < mm; i++){
        acc[i + 1] = s[i];
        acc[i + 1] += acc[i];
    }

    if(n - r < r) r = n - r;
    map<int, int> mp;
    for(int i = 0; i < mm; i++){
        mp[s[i]]++;
    }

    vector<int> w;
    vector<int> l;
    
    for(auto x : mp){
        w.push_back(x.first);
        l.push_back(x.second);
    }

    int k = w.size();
    
    /*
    cerr << k << endl;
    for(int i = 0; i < k; i++) cerr << w[i] << " " << l[i];
    cerr << endl;
    */

    vector<int> mono;
    for(int i = 0; i < k; i++){
        int val = 1;
        int sum = 0;
        for(;; val *= 2){
            sum += val;
            if(sum >= l[i]){
                sum -= val;
                val = l[i] - sum;
                mono.push_back(val * w[i]);
                break;
            }
            mono.push_back(val * w[i]);
        }
    }

    int kk = mono.size();
    
    /*
    for(int i = 0; i < kk; i++) cerr << mono[i] << " ";
    cerr << endl;*/
    int cur = 0;
    int nxt = 1;
    vector<vector<int>> dp(2, vector<int> (r + 10 * n, 0));
    dp[0][0] = 1;
    for(int i = 0; i < kk; i++){
        for(int j = 0; j <= r; j++){
            if(dp[cur][j] == 0) continue;
            
            // 使わない
            dp[nxt][j] = 1;
            dp[nxt][j + mono[i]] = 1;
            
        }
        swap(cur, nxt);
    }
    
    /*
    for(int j = 0; j <= r; j++){
        cerr << dp[cur][j] << " ";
    }
    cerr << endl;
    */
    if(dp[cur][r] == 1 or dp[cur][n - r] == 1) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 118064