#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int ll

const int maxn = 3e5 + 10;
vector<int> g[maxn];
int s[maxn];
int rsp[maxn];
vector<int> rsps;
int days[maxn];
int rspcnt[maxn];

list<int> o[maxn];

void dfs(int u = 1, int h = 0) {
    rspcnt[rsp[u]]++;
    days[u] = h;
    if (o[u].size() == 0) return;

    int z = o[u].front();
    auto zit = o[u].begin();
    for (auto it = o[u].begin(); it != o[u].end(); it++) {
        if (s[*it] > s[z]) {
            z = *it;
            zit = it;
        }
    }

    o[u].erase(zit);
    o[z].splice(o[z].end(), o[u]);
    dfs(z, h + 1);
}

void solve() {
    int n, q;
    cin >> n >> q;

    for (int i = 2; i <= n; i++) {
        int p;
        cin >> p;
        g[p].emplace_back(i);
        o[p].emplace_back(i);

        if (p == 1) {
            rsps.emplace_back(i);
            rsp[i] = i;
        } else rsp[i] = rsp[p];
    }

    for (int i = 1; i <= n; i++) {
        cin >> s[i];
    }

    sort(rsps.begin(), rsps.end(), [](int i, int j) {
       return rspcnt[i] < rspcnt[j];
    });

    while (q--) {
        int v;
        cin >> v;
        if (rsps.back() == rsp[v]) {
            cout << days[v] - rspcnt[rsps[rsps.size() - 2]];
        } else {
            cout << days[v] - rspcnt[rsps.back()];
        }
        cout << " ";
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
#ifdef local
    freopen("i.txt", "r", stdin);
    freopen("o.txt", "w", stdout);
#endif
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}
