//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
//#pragma GCC target("avx, avx2, tune=native")
#define int long long
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define pi pair<int, int>


using namespace std;

vector<vector<int>> g;
vector<int> tin, tout;
int T = 0;

void precalc(int u, int p) {
    tin[u] = T++;
    for (auto& v : g[u]) {
        if (v == p) continue;
        precalc(v, u);
    }
    tout[u] = T++;
}

void solve() {
    int n, q;
    cin >> n >> q;
    g.assign(n, {});
    tin.assign(n, 0);
    tout.assign(n, 0);
    vector<int> s(n), col(n);
    vector<int> pr(n);
    int c = 0;
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        --p;
        pr[i] = p;
        if (p == 0) {
            col[i] = c++;
        } else {
            col[i] = col[p];
        }
        g[p].push_back(i);
    }
    precalc(0, 0);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        s[i] = -s[i];
    }
    set<pi> st;
    vector<int> pos(n);
    int cnt = 0;
    vector<int> a;
    st.insert({0, 0});
    while (!st.empty()) {
        int u = st.begin()->s;
        pos[u] = cnt++;
        a.push_back(u);
        st.erase(st.begin());
        for (auto& v : g[u]) {
            st.insert({s[v], v});
        }
    }
    vector<int> rs(n);
    pi f = {-1, -1};

    auto check = [&](int u, int v) {
        return tin[u] <= tin[v] && tout[u] >= tout[v];
    };

    vector<pair<pi, pi>> mx(n, {f, f});
    vector<int> sum(n);
    for (int i = 1; i < n; ++i) {
        int u = a[i];

        int cr = pr[u];
        do{
            cr = pr[cr];
            if (mx[cr].f != f) {
                if (!check(mx[cr].f.s, u)) {
                    rs[u] = max(rs[u], mx[cr].f.f);
                } else {
                    rs[u] = max(rs[u], mx[cr].s.s);
                }
            }
        } while (cr);

        ++sum[u];
        pi prev = {sum[u], u};

        do{
            cr = pr[cr];
            if (prev.f >= mx[cr].f.f) {
                mx[cr].s = mx[cr].f;
                mx[cr].f = prev;
            } else if (prev.f >= mx[cr].s.f) {
                mx[cr].s = prev;
            }
            ++sum[cr];
            prev = {sum[cr], cr};
        } while (cr);

    }

    for (int i = 0; i < q; ++i) {
        int u;
        cin >> u;
        --u;
        cout << pos[u] - rs[u] << " \n"[i == q - 1];
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}
