#include<bits/stdc++.h>
using namespace std;

int N,K;
int par[100010];
vector<int> G[100010];
int ans = 0;

int DFS(int v)
{
    int d = 0;
    for(int i = 0; i < G[v].size(); i++)
        d = max(DFS(G[v][i]),d);
        
    if(d == K - 1 && par[v] != 1 && v != 1)
    {
        ans++;
        return 0;
    }
    return d + 1;
}

int main()
{
    scanf("%d%d",&N,&K);
    for(int i = 1; i <= N; i++)
    {
        int a;
        scanf("%d",&a);
        par[i] = a;
        if(i == 1)continue;
        G[a].push_back(i);
    }

    DFS(1);

    printf("%d\n",ans + (par[1] != 1));
    return 0;
}
