//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <iomanip>

using namespace std;

long long n, q;
vector<vector<long long>> g;
vector<long long> pr, s, ans1, zap, zap2, dp, used, rev;
//multiset<long long> pod;
set<long long> stm;
vector<pair<long long, long long>> mx1, mx2;

long long parent(long long v) {
	if (used[v] == 1)
		return v;
	else
		return pr[v] = parent(pr[v]);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> n >> q;

	g.resize(n);
	rev.resize(n + 1);
	pr.resize(n, -1);
	used.resize(n, 0);
	s.resize(n);
	zap.resize(n, 0);
	ans1.resize(n, 0);
	zap2.resize(q, 0);
	dp.resize(n, 0);
	mx1.resize(n, { 0, -1 });
	mx2.resize(n, { 0, -1 });

	for (long long i = 1; i < n; ++i) {
		cin >> pr[i];
		--pr[i];
		g[pr[i]].push_back(i);
	}

	for (long long i = 0; i < n; ++i) {
		if (pr[i] < 1 || g[pr[i]].size() > 1 || g[i].size() > 1) {
			used[i] = 1;
			if (g[i].size() > 1) {
				mx1[i] = { 0, g[i][0] };
				mx2[i] = { 0, g[i][1] };
			}
		}
	}

	for (long long i = 1; i < n; ++i)
		pr[i] = parent(pr[i]);

	for (long long i = 0; i < n; ++i) {
		cin >> s[i];
		rev[s[i]] = i;
	}

	for (long long i = 0; i < q; ++i) {
		cin >> zap2[i];
		--zap2[i];
		zap[zap2[i]] = 1;
	}

	long long sh = 0;
	stm.insert(s[0]);

	while (!stm.empty()) {
		long long ind = rev[(*(--stm.end()))];
		stm.erase((--stm.end()));
		if (zap[ind] == 1) {
			long long x3 = 0;

			long long a = ind;
			while (pr[a] != -1) {
				if (g[pr[a]].size() > 1) {
					if (mx1[pr[a]].second != a)
						x3 = max(x3, mx1[pr[a]].first);
					else
						x3 = max(x3, mx2[pr[a]].first);
				}
				a = pr[a];
			}
			ans1[ind] = sh - x3;
		}
		++dp[ind];
		long long a = ind;
		while (pr[a] != -1) {
			if (mx1[pr[a]].second == a) {
				++mx1[pr[a]].first;
			}
			else {
				if (mx2[pr[a]].second == a) {
					++mx2[pr[a]].first;
				}
				else {
					if (mx2[pr[a]].first < dp[a]) {
						mx2[pr[a]] = { dp[a], a };
					}
				}
			}
			if (mx1[pr[a]].first < mx2[pr[a]].first)
				swap(mx1[pr[a]], mx2[pr[a]]);
			++dp[pr[a]];
			a = pr[a];
		}

		for (long long i = 0; i < g[ind].size(); ++i) {
			stm.insert(s[g[ind][i]]);
		}

		++sh;
	}

	for (long long i = 0; i < q; ++i)
		cout << ans1[zap2[i]] << ' ';

	return 0;
};
