//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast,unroll-loops")
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <numeric>
#include <algorithm>
#include <random>
using ll = long long;
//#define int ll
#define all(a) a.begin(), a.end()

using namespace std;
//using namespace __gnu_pbds;

//using odered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rnd(0);

vector<int> par, s, sz, e, pos, up;
vector<vector<int>> g;

void dfs(int v) {
	sz[v] = 1;
	for (auto to : g[v]) {
		dfs(to);
		sz[v] += sz[to];
	}
}

void dfs2(int v) {
	pos[v] = e.size();
	e.push_back(v);
	for (int i = 0; i < g[v].size(); i++) {
		int to = g[v][i];
		if (i == 0) {
			up[to] = up[v];
		}
		else {
			up[to] = to;
		}
		dfs2(to);
	}
}

struct Node {
	int max, psh;
};

vector<Node> t;
vector<pair<int, Node>> tmp;

void psh(int v, int l, int m, int r) {
	tmp.push_back({ v * 2 + 1, t[v * 2 + 1] });
	tmp.push_back({ v * 2 + 2, t[v * 2 + 2] });
	if (t[v].psh == -1) {
		t[v * 2 + 1].psh = t[v * 2 + 2].psh = -1;
		t[v * 2 + 1].max = t[v * 2 + 2].max = 0;
	}
	t[v * 2 + 1].psh += t[v].psh;
	t[v * 2 + 2].psh += t[v].psh;
	t[v * 2 + 1].max += t[v].psh;
	t[v * 2 + 2].max += t[v].psh;
	t[v].psh = 0;
}

void add(int v, int l, int r, int lq, int rq) {
	if (lq <= l && r <= rq) {
		t[v].max++;
		t[v].psh++;
		return;
	}
	if (lq >= r || rq <= l) {
		return;
	}
	int m = (l + r) / 2;
	psh(v, l, m, r);
	add(v * 2 + 1, l, m, lq, rq);
	add(v * 2 + 2, m, r, lq, rq);
	t[v].max = max(t[v * 2 + 1].max, t[v * 2 + 2].max);
}

void st(int v, int l, int r, int lq, int rq) {
	tmp.push_back({ v, t[v] });
	if (lq <= l && r <= rq) {
		t[v].max = 0;
		t[v].psh = -1;
		return;
	}
	if (lq >= r || rq <= l) {
		return;
	}
	int m = (l + r) / 2;
	psh(v, l, m, r);
	st(v * 2 + 1, l, m, lq, rq);
	st(v * 2 + 2, m, r, lq, rq);
	t[v].max = max(t[v * 2 + 1].max, t[v * 2 + 2].max);
}

void solve() {
	int n, q;
	cin >> n >> q;
	par.resize(n);
	g.resize(n);
	s.resize(n);
	sz.resize(n);
	pos.resize(n);
	up.resize(n);
	t.resize(n * 4);
	for (int i = 1; i < n; i++) {
		cin >> par[i];
		par[i]--;
		g[par[i]].push_back(i);
	}
	dfs(0);
	for (auto& i : g) {
		for (int j = 1; j < i.size(); j++) {
			if (sz[i[j]] > sz[i[0]]) {
				swap(i[j], i[0]);
			}
		}
	}
	dfs2(0);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	vector<int> ans(n);
	vector<set<pair<int, int>>> gs(n);
	for (int i = 0; i < n; i++) {
		for (auto to : g[i]) {
			gs[i].insert({ s[to], to });
		}
	}
	int tm = 0;
	while (gs[0].size()) {
		auto to = prev(gs[0].end())->second;
		gs[0].erase(prev(gs[0].end()));
		for (auto w : gs[to]) {
			gs[0].insert(w);
		}
		int to1 = to;
		while (to1 != 0) {
			add(0, 0, n, pos[up[to1]], pos[to1] + 1);
			if (up[to1] == 0) break;
			to1 = par[up[to1]];
		}

		tmp.clear();
		ans[to] = 1e9;
		tm++;

		to1 = to;
		while (1) {
			st(0, 0, n, pos[up[to1]], pos[to1] + 1);
			if (up[to1] == 0) break;
			to1 = par[up[to1]];
		}

		ans[to] = tm - t[0].max;
		for (int j = int(tmp.size()) - 1; j >= 0; j--) {
			t[tmp[j].first] = tmp[j].second;
		}
	}
	while (q--) {
		int i;
		cin >> i;
		i--;
		cout << ans[i] << ' ';
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef LOCAL
	auto f1 = freopen("input.txt", "r", stdin);
	auto f2 = freopen("output.txt", "w", stdout);
#endif

	solve();
}