#include<bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,bmi,bmi2,sse,sse2,sse3,sse4")
using namespace std;
vector<int>g[300005 + 1] = {};
int tin[300005];
int tout[300005];
int sz[300005];
int hd[300005];
int p[300005];
int t = 0;
void calc_sz(int v) {
    sz[v] = 1;
    // reverse(g[v].begin(), g[v].end());
    for (auto u : g[v]) {
        calc_sz(u);
        sz[v] += sz[u];
    }
}
void dfs(int v) {
    for (auto &u : g[v]) {
        if (sz[u] > sz[g[v][0]]) {
            swap(u, g[v][0]);
        }
    }
    tin[v] = ++t;
    for (auto &u : g[v]) {
        hd[u] = (u == g[v][0] ? hd[v] : u);
        dfs(u);
    }
}
int st[1200005];
int mod[2400005];
void push(int v) {
    st[v] += mod[v];
    mod[v * 2] += mod[v];
    mod[v * 2 + 1] += mod[v];
    mod[v] = 0;
}
void add(int v, int tl, int tr, int l, int r, int val) {
    push(v);
    if (tl == l && tr == r) {
        mod[v] += val;
        push(v);
        return;
    } else if (l > r) {
        return;
    } else {
        int tm = (tl + tr) >> 1;
        add(v * 2, tl, tm, l, min(r, tm), val);
        add(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, val);
        st[v] = max(st[v * 2], st[v * 2 + 1]);
    }
}
int get(int v, int tl, int tr, int l, int r) {
    push(v);
    if (tl == l && tr == r) {
        return st[v];
    } else if (l > r) {
        return 0;
    } else {
        int tm = (tl + tr) >> 1;
        return max(get(v * 2, tl, tm, l, min(r, tm)), get(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
    }
}
int n, m;
void add_pr(int v) {
    // cout << v << endl;
    // cout << "+ " << v << endl;
    while (v) {
        // cout << v << ' ' << hd[v] << endl;
        add(1, 1, n, tin[hd[v]], tin[v], 1);
        v = p[hd[v]];
    }
}
int get(int v) {
    // cout << "get " << v << endl;
    int ans = 0;
    pair<int, int>sg[20];
    int sz = 0;
    while (v) {
        sg[sz++] = {tin[hd[v]], tin[v]};
        // assert(sz < 20);
        v = p[hd[v]];
    }
    reverse(sg, sg + sz);
    int pr = 0;
    for (int i = 0; i < sz; i++) {
        // cout << pr + 1 << ' ' << sg[i].first - 1 << endl;
        ans = max(ans, get(1, 1, n, pr + 1, sg[i].first - 1));
        pr = sg[i].second;
    }
    ans = max(ans, get(1, 1, n, pr + 1, n));
    // cout << "TOT " << ans << endl;
    return ans;
}
void gogo() {
    cin >> n >> m;
    for (int i = 2; i <= n; i++) {
        cin >> p[i];
        g[p[i]].push_back(i);
    }
    int s[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
    }
    bool was[n + 1] = {};
    was[1] = 1;
    priority_queue<pair<int, int> >q;
    q.push({s[1], 1});
    int cnt = 0;
    vector<int>ord = {0};
    while (!q.empty()) {
        pair<int, int>m = q.top();
        q.pop();
        ord.push_back(m.second);
        for (auto u : g[m.second]) {
            if (!was[u]) {
                q.push({s[u], u});
                was[u] = 1;
            }
        }
    }
    hd[1] = 1;
    calc_sz(1);
    dfs(1);
    int pos[n + 1];
    for (int i = 1; i <= n; i++) {
        pos[ord[i]] = i;
    }
    vector<pair<int, pair<int, int> > >qq;
    int res[m + 1] = {};
    for (int i = 1; i <= m; i++) {
        int v;
        cin >> v;
        qq.push_back({pos[v], {v, i}});
    }
    sort(qq.begin(), qq.end());
    int er = 0;
    int ans[n + 1] = {};
    for (auto u : qq) {
        while (er < u.first) {
            er++;
            add_pr(ord[er]);
        }
        res[u.second.second] = u.first - 1 - get(u.second.first);
        // cout << endl;
    }
    for (int i = 1; i <= m; i++) {
        cout << res[i] << ' ';
    }
}
main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        gogo();
    }
}
//0 62 46 21
//104