#include<bits/stdc++.h>
using namespace std;
int n,k,a[1<<17],cnt;vector<int>x[1<<17];
int D(int p) {int M=0;for(int i=0;i<x[p].size();i++){M=max(M,D(x[p][i])+1);}if(M==k-1&&p!=1&&a[p]!=1){M=-1;cnt++;}return M;}
int main(){cin>>n>>k;for(int i=1;i<=n;i++){cin>>a[i];if(i>=2){x[a[i]].push_back(i);}}if(a[1]!=1){a[1]=1;cnt++;}D(1);cout<<cnt<<endl;}