#include <bits/stdc++.h>

using namespace std;

//#define int int64_t
#define fi first
#define se second

const int N = 3e5 + 12;
vector <int> g[N];
int a[N], ans[N], pr[N];

int sz[N], n;
void calc_sz(int v) {
    sz[v] = 1;
    for(auto to : g[v]) {
        calc_sz(to);
        sz[v] += sz[to];
    }
    return;
}
int tin[N], timer = 0, head[N];
void dfs(int v) {
    if(head[v] == 0)
        head[v] = v;
    timer++;
    tin[v] = timer;
    int big = -1;
    for(auto to : g[v]) {
        if(big == -1 || sz[to] > sz[big]) {
            big = to;
            break;
        }
    }
    if(big == -1)
        return;
    head[big] = head[v];
    dfs(big);
    for(auto to : g[v]) {
        if(to == big)
            continue;
        dfs(to);
    }
    return;
}
int t[4*N], dop[4*N];
void push(int v) {
    if(dop[v] == 0)
        return;
    dop[v*2] += dop[v];
    dop[v*2+1] += dop[v];
    t[v*2] += dop[v];
    t[v*2+1] += dop[v];
    dop[v] = 0;
    return;
}
void upd(int v, int vl, int vr, int l, int r) {
    if(l <= vl && vr <= r) {
        dop[v] += 1;
        t[v] += 1;
        return;
    }
    push(v);
    int mid = (vl + vr) >> 1;
    if(l <= mid)
        upd(v * 2, vl, mid, l, r);
    if(mid + 1 <= r)
        upd(v * 2 + 1, mid + 1, vr, l, r);
    t[v] = max(t[v*2], t[v*2+1]);
    return;
}
int get(int v, int vl, int vr, int l, int r) {
    if(l <= vl && vr <= r)
        return t[v];
    push(v);
    int mid = (vl + vr) >> 1, ans = 0;
    if(l <= mid)
        ans = max(ans, get(v * 2, vl, mid, l, r));
    if(mid + 1 <= r)
        ans = max(ans, get(v * 2 + 1, mid + 1, vr, l, r));
    return ans;
}

void upd(int v) {
    while(v != 0) {
        upd(1, 1, timer, tin[head[v]], tin[v]);
        v = pr[head[v]];
    }
    return;
}
int calc(int v) {
    vector <pair<int,int>> segs;
    while(v != 0) {
        segs.push_back({tin[head[v]], tin[v]});
        v = pr[head[v]];
    }
    reverse(segs.begin(), segs.end());
    int ans = 0;
    for(int i = 1; i < segs.size(); ++i) {
        if(segs[i-1].se + 1 <= segs[i].fi - 1)
            ans = max(ans, get(1, 1, timer, segs[i-1].se + 1, segs[i].fi - 1));
    }
    if(segs.back().se + 1 <= timer)
        ans = max(ans, get(1, 1, timer, segs.back().se + 1, timer));
    return ans;
}

int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int qq;
    cin >> n >> qq;
    for(int i = 2; i <= n; ++i) {
        cin >> pr[i];
        g[pr[i]].push_back(i);
    }
    dfs(1);
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    set <pair<int,int>> st;
    for(auto to : g[1]) {
        st.insert({a[to], to});
    }
    int it = 1;
    while(st.size()) {
        pair<int,int> mx = *st.rbegin();
        ans[mx.se] = it - calc(mx.se);
        it++;
        upd(mx.se);
        st.erase(mx);
        for(auto to : g[mx.se]) {
            st.insert({a[to], to});
        }
    }
    while(qq--) {
        int v;
        cin >> v;
        cout << ans[v] << ' ';
    }
    return 0;
}
