//#pragma GCC target("avx, avx2")
#pragma GCC optimize("O3, Ofast, unroll-loops")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <iomanip>
#include <random>
#include <vector>
#include <map>
#include <queue>
#include <set>


using namespace std;
using ll = long long;
const ll MAX = 1e18;
const ll MIN = -1e18;

#define all(a) a.begin(), a.end()
#define each(x, a) for(auto &x : a)


struct P {
	ll f, s;
};


vector<vector<ll>> g;
vector<ll> s, pred;
ll timer = 1;
vector<ll> tin, tout;
void dfs(ll v, ll p) {
	tin[v] = timer++;
	for (auto to : g[v]) {
		if (to == p) continue;
		dfs(to, v);
	}
	tout[v] = timer++;
}
bool is_ab(ll a, ll b) {
	return (tin[a] <= tin[b] && tout[b] <= tout[a]);
}

vector<ll> sz;
void dfs2(ll v, ll p) {
	for (auto to : g[v]) {
		if (to == p) continue;
		dfs2(to, v);
		sz[v] += sz[to];
	}
}


void solve() {
	ll n, Q;
	cin >> n >> Q;
	g.resize(n);
	pred.resize(n);
	for (int i = 1; i < n; ++i) {
		ll p; cin >> p; p--;
		g[p].push_back(i);
		pred[i] = p;
	}
	s.resize(n);
	each(x, s) {
		cin >> x;
	}

	tin.resize(n, 0);
	tout.resize(n, 0);
	dfs(0, 0);

	vector<ll> ans(n, 0);

	set<pair<ll, ll>> q;
	q.insert({ s[0], 0 });
	sz.assign(n, 0);
	//vector<ll> used(n, 0); used[0] = 1;
	vector<ll> ord, revord(n, -1);
	timer = 0;
	vector<P> mxx(n, { 0, 0 });
	while (!q.empty()) {
		auto qwe = *q.begin();
		ll w = qwe.first, v = qwe.second;
		q.erase(qwe);
		ord.push_back(v);
		ans[v] = sz[0];
		revord[v] = timer++;
		if (v) {
			ans[v] = ans[pred[v]] + revord[v] - revord[pred[v]];
			/*if (mxx[pred[v]].f == sz[v] + 1) {
				ans[v] = max(ans[v], sz[0])
			}*/
		}
		
		for (auto to : g[v]) {
			q.insert({ -s[to], to });
		}
		while (v != 0) {
			sz[v]++;
			if (mxx[pred[v]].f < sz[v]) {
				mxx[pred[v]].s = mxx[pred[v]].f;
				mxx[pred[v]].f = sz[v];
			}
			else if (mxx[pred[v]].s < sz[v]) {
				mxx[pred[v]].s = sz[v];
			}
			v = pred[v];
		}
		sz[v]++;
	}
	for (int i = 1; i < n; ++i) {
		ans[i]--;
	}
	for (int i = 0; i < Q; ++i) {
		ll  ver;
		cin >> ver;
		ver--;
		cout << ans[ver] << '\n';
	}
}


signed main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll t = 1;
	 //cin >> t;
	while (t--) {
		solve();
		cout << '\n';
	}
}