#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
void read(int &x) {
	char ch; bool ok;
	for(ok=0,ch=getchar(); !isdigit(ch); ch=getchar()) if(ch=='-') ok=1;
	for(x=0; isdigit(ch); x=x*10+ch-'0',ch=getchar()); if(ok) x=-x;
}
#define rg register
const int maxn=1e5+10;bool vis[maxn];
int n,k,dep[maxn],ans,f[maxn],cnt,pre[maxn*2],nxt[maxn*2],h[maxn];
void add(int x,int y){
	pre[++cnt]=y,nxt[cnt]=h[x],h[x]=cnt;
}
void dfs(int x){
	vis[x]=1;
	for(rg int i=h[x];i;i=nxt[i])
		if(!vis[pre[i]])dfs(pre[i]),dep[x]=max(dep[pre[i]]+1,dep[x]);
	if(dep[x]>=k-1&&f[x]!=1)dep[x]=-1,ans++;
}
int main()
{
	read(n),read(k);scanf("%d",&f[1]);
	for(rg int i=2;i<=n;i++)read(f[i]),add(f[i],i);
	if(f[1]!=1)ans++,f[1]=1;dfs(1);
	printf("%d\n",ans);
}
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
using namespace std;
int a[100000];
vector <int> children[100000];
int d[100000];
bool done[100000];
void set_d(int cur, int cur_d){
  d[cur] = cur_d;
  for(int i = 0; i < children[cur].size(); i++){
    set_d(children[cur][i], cur_d + 1);
  }
}

void set_done(int cur){
  if(done[cur]){
    return;
  }
  done[cur] = true;
  for(int i = 0; i < children[cur].size(); i++){
    set_done(children[cur][i]);
  }
}

int main(){
  int N;
  long long K;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    a[i] --;
    if(i != 0){
      children[a[i]].push_back(i);
    }
  }

  for(int i = 0; i < N; i++){
    d[i] = INT_MAX;
  }

  set_d(0, 0);
  int ans;
  if(a[0] == 0){
    ans = 0;
  } else {
    ans = 1;
  }

  vector <pair <int, int> > tmp;
  for(int i = 0; i < N; i++){
    if(d[i] <= K){
      //done[i] = true;
    } else {
      tmp.push_back(make_pair(d[i], i));
    }
  }
  sort(tmp.begin(), tmp.end());
  reverse(tmp.begin(), tmp.end());

  for(int i = 0; i < tmp.size(); i++){
    int cur_d = tmp[i].first;
    int cur = tmp[i].second;
    if(!done[cur]){
      int teleport = cur;
      for(int i = 0; i < K - 1; i++){
        teleport = a[teleport];
      }
      ans ++;
      set_done(teleport);
    }

  }

  cout << ans << endl;
  return 0;
}
