#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, M = 2010, B = 2000;
int n, k, a[N], dep[N], dfn[N], bk[N], tot;
vector<int> g[N], p[N], col[N];
void dfs(int u, int fa) {
dfn[u] = bk[u] = ++tot;
for (int v : g[u]) {
if (v != fa) {
dfs(v, u), bk[u] = max(bk[u], bk[v]);
}
}
}
void dfs1(int u, int fa) {
dep[u] = dep[fa] + 1;
for (int v : g[u]) {
if (v != fa) {
dfs1(v, u);
if (p[u].size() < p[v].size()) swap(p[u], p[v]);
for (int i = p[u].size() - 1, j = p[v].size() - 1; j >= 0; i--, j--) {
p[u][i] += p[v][j];
}
}
}
p[u].push_back(1);
if (col[a[u]].size() <= B) {
vector<int> tmp = p[u];
int cnt = 0;
for (int x : col[a[u]]) {
int k = dep[x] - dep[u];
if (k >= 0 && tmp[tmp.size() - 1 - k]) tmp[tmp.size() - k - 1]--, cnt++;
}
}
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i], col[a[i]].push_back(i);
}
for (int i = 2, fa; i <= n; i++) {
cin >> fa, fa++, g[fa].push_back(i);
}
dfs(1, 0), dfs1(1, 0);
for (int i = 1; i <= k; i++) {
if (cnt[i] > B)
}
return 0;
}