#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <array>
#include <queue>

using namespace std;
typedef int ll;
typedef long double ld;
#define all(a) a.begin(), a.end()
const ll INF = 2e9;
const ll N = 1 << 19;
vector<ll> g[N]{};
ll n, q, p[N]{}, pbig[N], mnbig[N], firmn[N]{}, h[N]{}, s[N], sm[N]{}, smp[N]{}, mx1[N]{}, mx2[N]{};
char isd[N]{};
ll seg[2 * N];
void upd(ll x, ll d) {
	seg[N + x] = d;
	for (ll v = (N + x) / 2; v > 0; v /= 2) {
		seg[v] = min(seg[v * 2], seg[v * 2 + 1]);
	}
}

ll get(ll d, ll v = 1, ll l = 0, ll r = N) {
	if (l + 1 == r) return l;
	ll m = (l + r) / 2;
	if (seg[v * 2 + 1] < d) return get(d, v * 2 + 1, m, r);
	return get(d, v * 2, l, m);
}

void first_dfs(ll v, ll stbig, ll mnlast, vector<ll>& st) {
	h[v] = h[p[v]] + 1;
	upd(h[v], s[v]);
	st.push_back(v);
	firmn[v] = st[get(s[v]) + 1];
	mnlast = min(mnlast, s[v]);
	pbig[v] = stbig;
	mnbig[v] = mnlast;
	for (ll u : g[v]) {
		if (g[v].size() >= 2)
			first_dfs(u, u, N, st);
		else
			first_dfs(u, stbig, mnlast, st);
	}
	upd(h[v], N);
	st.pop_back();
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> q;
	p[1] = 0, h[0] = 0;
	for (ll i = 2; i <= n; i++) {
		cin >> p[i];
		g[p[i]].push_back(i);
	}
	for (ll i = 1; i <= n; i++) cin >> s[i];
	/*for (ll i = 1; i <= n; i++) {
		if (s[i] > s[1]) s[i]--;
	}
	s[1] = n;*/
	fill(seg, seg + 2 * N, N);
	upd(0, 0);
	vector<ll> st = { 0 };
	first_dfs(1, 1, 0, st);
	vector<ll> rs(n + 1);
	for (ll i = 1; i <= n; i++) {
		rs[s[i]] = i;
	}
	vector<vector<array<ll, 2>>> z(n + 1);
	vector<ll> ans(q, 0), mx(q, 0);
	for (ll j = 0; j < q; j++) {
		ll v;
		cin >> v;
		if (v > 1) {
			ans[j] = h[v] - 1;
			ll mn = mnbig[v];
			v = pbig[v];
			while (v > 1) {
				ll u = p[v];
				z[mn].push_back({ v, j });
				mn = min(mn, mnbig[u]);
				v = pbig[u];
			}
		}
	}
	for (ll y = n; y >= 1; y--) {
		ll x = rs[y];
		ll d = 1 + smp[x];
		sm[x] = 0;
		ll v = x;
		while (v >= 1 && s[v] >= y) {
			ll u = p[v];
			if (sm[v] == mx1[u]) {
				sm[v] += d;
				mx1[u] = sm[v];
			}
			else {
				sm[v] += d;
				if (sm[v] > mx1[u]) {
					mx2[u] = mx1[u];
					mx1[u] = sm[v];
				}
				else if (sm[v] > mx2[u]) {
					mx2[u] = sm[v];
				}
			}
			smp[u] += d;
			if (v == firmn[x]) {
				break;
			}
			else {
				if (mnbig[u] >= y) {
					v = pbig[u];
				}
				else {
					v = firmn[x];
				}
			}
		}
		/*ll mn = mnbig[x];
		ll v = pbig[x];
		while (mn >= x && v > 1) {
			ll u = p[v];
			if (mx1[u] == sm[v]) {
				mx1[u] = sm[v] + sm[x];
				sm[v] += sm[x];
			}
			else {
				sm[v] += sm[x];
				if (sm[v] > mx1[u]) {
					mx2[u] = mx1[u];
					mx1[u] = sm[v];
				}
				else if (sm[v] > mx2[u]) {
					mx2[u] = sm[v];
				}
			}
			mn = min(mn, mnbig[u]);
			if (pbig[u] != u) {
				sm[u] += 
				v = pbig[u];
			}
		}*/
		for (array<ll, 2> m : z[y]) {
			ll j = m[1], v = m[0], u = p[v];
			ans[j] += smp[u] - sm[v];
			ll res = 0;
			if (sm[v] == mx1[u]) res = mx2[u];
			else res = mx1[u];
			mx[j] = max(res, mx[j]);
		}
	}
	for (ll j = 0; j < q; j++) {
		cout << ans[j] - mx[j] << " ";
	}
	cout << "\n";
	return 0;
}