// #pragma GCC optimize("O3,Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define speedup cin.tie(0)->sync_with_stdio(0);
#define bitcount __builtin_popcount
#define int long long
#define pb push_back
#define vc vector
inline void solve() {
int n, k;
cin >> n >> k;
vc<vc<int>> adj (n);
for (int a = 1; a < n; a++) {
int b; cin >> b;
adj[a].pb(b);
adj[b].pb(a);
}
auto good = [&](int mask) -> bool {
bool good = 1;
auto dfs = [&](auto &&dfs, int a, int p, int d) -> void {
for (int b : adj[a]) {
if (b == p) continue;
if (mask >> b & 1) {
if (d + 1 < k) good = 0;
} else dfs(dfs, b, a, d + 1);
}
};
for (int i = 0; i < n; i++)
if (mask >> i & 1) dfs(dfs, i, i, 0);
return good;
};
int ans = 0;
for (int mask = 1; mask < (1 << n); mask++)
if (good(mask)) ans = max(ans, (int)bitcount(mask));
cout << ans;
}
signed main() {
speedup;
solve();
return 0;
}