//
// created by Vadim in 12/34/56
//

#include <bits/stdc++.h>

using namespace std;

vector<vector<int>> g(3e5);
vector<int> d(3e5);
int tin[300000], tout[300000];
int cn = 1;

void dfs(int u) {
    d[u] = 1;
    tin[u] = cn++;
    for (int v : g[u]) {
        dfs(v);
        d[u] += d[v];
    }
    tout[u] = cn++;
}

void solve() {
    int n, q; cin >> n >> q;
    for (int i = 0; i < n - 1; i++) {
        int p; cin >> p;
        g[p].push_back(i + 2);
    }
    vector<int> s(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    sort(g[1].begin(), g[1].end(), [s](int a, int b) {
       return s[a] > s[b];
    });
    dfs(1);
    vector<int> tmp;
    for (auto v : g[1]) {
        tmp.push_back(v);
    }
    sort(tmp.begin(), tmp.end(), [&](int a1, int b1) {
        return d[a1] > d[b1];
    });
    while (q--) {
        int x; cin >> x;
        int ans = d[1] - d[x];
        if (ans == 0) {
            cout << 0 << " ";
            continue;
        }
        for (int v : tmp) {
            if (!(tin[v] <= tin[x] && tout[v] >= tout[x])) {
                ans -= d[v];
                break;
            }
        }
        cout << ans << " ";
    }
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}
