#include<stdio.h>
#include<vector>
#define pb push_back
using namespace std;

int S;
int c[100005],g[100005],a[100005];
vector<int> r[100005];
int l;

int f(int x)
{
    int i,h=0;
    c[x]++;
    for(i=0;i<r[x].size();i++){
        if(c[r[x][i]])continue;
        g[r[x][i]]=x;
        h=max(h,f(r[x][i]));
    }
    h++;
    if(h==l&&g[x]!=1)h=0,S++;
    return h;
}

int main()
{
    int n,i;
    scanf("%d %d", &n, &l);
    for(i=1;i<=n;i++){
        scanf("%d", &a[i]);
    }
    if(a[1]!=1)a[1]=1,S++;
    g[1]=1;
    for(i=1;i<=n;i++){
        r[a[i]].pb(i);
    }
    f(1);
    printf("%d", S);
    return 0;
}
