#include <bits/stdc++.h>

const int N = 100054;

int n, K, ans;
int p[N], fc[N], nc[N], f[N];

inline void up(int &x, const int y) {x < y ? x = y : 0;}
inline void link(int x, int px) {nc[x] = fc[px], fc[px] = x;}

void dfs(int x, int dep = 0) {
	for (int y = fc[x]; y; y = nc[y]) dfs(y, dep + 1), up(f[x], f[y] + 1);
	if (dep > 1 && f[x] >= K - 1) ++ans, f[x] = -1;
}

int main() {
	scanf("%d%d%d", &n, &K, &ans), ans = ans != 1;
	for (int i = 2; i <= n; ++i) scanf("%d", p + i), link(i, p[i]);
	dfs(1), printf("%d\n", ans);
	return 0;
}
#include <bits/stdc++.h>

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int n, k, r, a[100100];
vector<int> e[100100];

int dfs(int i = 0) {
  int d = 0;
  for (int j : e[i])
    d = max(d, dfs(j) + 1);
  if (d + 1 >= k) {
    r += a[i] != 0;
    return -1;
  }
  return d;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n >> k;
  for (int i = 0; i < n; i++)
    cin >> a[i], a[i]--;
  r += a[0] != 0;
  a[0] = 0;
  for (int i = 1; i < n; i++)
    e[a[i]].push_back(i);
  dfs();
  cout << r << "\n";
}
