#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,x,n) for (int i = x;i < n;++i)

vector<int> tr[100001];
int n, k, c, an;

int go(int v = 1, bool f = false) {
	int d = 0;
	f(i, 0, tr[v].size())d = max(d, go(tr[v][i], v != 1));
	if (++d == k && f)++an, d = 0;
	return d;
}

int main() {
	scanf("%d%d", &n, &k);
	scanf("%d", &c);
	if (c != 1)++an;
	f(i, 2, n + 1) {
		int t;
		scanf("%d", &t);
		tr[t].push_back(i);
	}
	go();
	printf("%d", an);
}