#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long int lli;
const lli inf = 1e18;
const lli mod = 1e9 +7;
typedef pair<lli, lli> pll;

int main(){
	int n,r;
	cin >> n >> r;
	vector<int> p(n);
	for(int i=0; i<n; i++){
		cin >> p[i];
		p[i]--;
	}
	map<int, int> numsmap;
	vector<bool> used(n, false);
	for(int i=0; i<n; i++){
		if(used[i]) continue;
		used[i] = true;
		int curr = p[i];
		int num = 1;
		while(curr != i){
			used[curr] = true;
			curr = p[curr];
			num++;
		}
		numsmap[num]++;
	}

	vector<int> nums;
	for(auto p: numsmap){
		int key = p.first;
		int value = p.second;
		int power2 = 1;
		while(power2 <= value){
			nums.push_back(key*power2);
			value -= power2;
			power2 *= 2;
		}
		nums.push_back(key*value);
	}

	vector<bool> dp(n+1, false);
	dp[0] = true;
	for(int i: nums){
		for(int j=n; j>=0; j--){
			if(dp[j]) dp[j+i] = true;
		}
	}
	if(dp[r]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl; 
	}
	return 0;
}
