#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


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 count() const{
    return num;
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n,r;
  cin>>n>>r;
  vector<Int> ps(n);
  for(Int i=0;i<n;i++) cin>>ps[i],ps[i]--;

  UnionFind uf(n);
  for(Int i=0;i<n;i++) uf.unite(i,ps[i]);

  vector<Int> vs;
  for(Int i=0;i<n;i++)
    if(uf.find(i)==i) vs.emplace_back(uf.size(i));

  const Int BS = 600;
  vector<Int> cnt(BS,0);
  for(Int v:vs)
    if(v<BS) cnt[v]++;

  vector<Int> dp(n+1,0);
  dp[0]=1;
  for(Int w=1;w<BS;w++){
    vector<Int> nx(n+1,-1);
    for(Int i=0;i<=n;i++){
      if(dp[i]) chmax(nx[i],cnt[w]);
      if(nx[i]>0&&i+w<=n) chmax(nx[i+w],nx[i]-1);
    }
    for(Int i=0;i<=n;i++) dp[i]=nx[i]>=0;
  }

  for(Int v:vs){
    if(v<BS) continue;
    for(Int i=n;i>=0;i--)
      if(i+v<=n) dp[i+v]|=dp[i];
  }

  cout<<(dp[r]?"Yes":"No")<<endl;
  return 0;
}

