#include "bits/stdc++.h"

using namespace std;


struct unionfind
{
	//rankのオーバーフローに注意
	vector<int> par, rank;
	unionfind(int n)
	{
		par.resize(n);
		rank.resize(n);
		for (int i = 0; i < n; i++)
		{
			par[i] = i;
			rank[i] = 1;
		}
	}

	bool same(int u, int v)
	{
		return root(u) == root(v);
	}

	void unite(int u, int v)
	{
		u = root(u), v = root(v);
		if (u == v) return;
		if (rank[u] > rank[v]) swap(u, v);
		par[u] = v;
		rank[v] += rank[u];
	}

	int root(int v)
	{
		if (par[v] == v) return v;
		return par[v] = root(par[v]);
	}
};

void solve(void)
{
	int n, r, p;
	cin >> n >> r;
	unionfind uf(n);
	for (int i = 0; i < n; i++)
	{
		cin >> p;
		uf.unite(i, p-1);
	}
	vector<int> used(n), ws;
	for (int i = 0; i < n; i++)
	{
		if (used[uf.root(i)]) continue;
		ws.push_back(uf.rank[uf.root(i)]);
		used[uf.root(i)] = 1;
	}
	bitset<150010> dp;
	r = min(r, n - r);
	dp[0] = 1;
	for (int w : ws)
	{
		dp |= dp << w;
		if (dp[r])
		{
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


