#include <bits/stdc++.h>
#pragma GCC target("avx2")
//#define int long long
#define F first
#define S second
#define pb push_back

using namespace std;

int p[300030];
int s[300030];
int ans[300030];
//int pref[200030];
//int suf[200030];
int n;
int sq = 190;
vector <int> g[300030];
int day[300030];
vector <int> need[550];
vector <int> need2[550];

int cnt[300030];
int cnt2[300030];

bool us[300030];
bool us2[300030];

int res[300030];
int res2[300030];

int maxdel[300030];
int add2[300030];
int num[300030];


void add(int v, set <pair<int, int>> &st) {
    for(auto to : g[v]) {
        st.insert({s[to], to});
    }
}

void calc_cnt(int v) {
    cnt[v] = us[v];
    for(auto to : g[v]) {
        calc_cnt(to);
        cnt[v] += cnt[to];
    }
}

void calc_cnt2(int v) {
    cnt2[v] = us2[v];
    for(auto to : g[v]) {
        calc_cnt2(to);
        cnt2[v] += cnt2[to];
    }
}

void calc_ans(int v, int result) {
    res[v] = result;
    int sz = g[v].size();
    vector <int> pref(sz + 2, 0);
    vector <int> suf(sz + 2, 0);
    for(int i = 0; i < sz; i++) {
        pref[i + 1] = max(pref[i], cnt[g[v][i]]);
    }
    for(int i = sz - 1; i >= 0; i--) {
        suf[i + 1] = max(suf[i + 2], cnt[g[v][i]]);
    }
    for(int i = 0; i < sz; i++) {
        int newres = max({result, pref[i], suf[i + 2]});
        calc_ans(g[v][i], newres);
    }
}

void f_need(int v, vector <int> &c) {
    if(v != 1) {
        int pr = p[v];
        if(cnt2[pr] - cnt2[v] - us2[pr] != 0) {
            c.pb(v);
        }
    }
    if(num[v] != 0) {
        need[num[v]] = c;
    }
    for(auto to : g[v]) {
        f_need(to, c);
    }
    if(v != 1) {
        int pr = p[v];
        if(cnt2[pr] - cnt2[v] - us2[pr] != 0) {
            c.pop_back();
        }
    }
}

void f_need2(int v, vector <int> &c) {
    if(num[v] != 0) {
        for(auto to : c)
            need2[num[v]].pb(to);
    }
    for(auto to : g[v]) {
        f_need2(to, c);
        if(cnt2[to] != 0)
            c.pb(to);
    }
    for(auto to : g[v]) {
        if(cnt2[to] != 0)
            c.pop_back();
    }
}

void f_need3(int v, vector <int> &c) {
    if(num[v] != 0) {
        for(auto to : c)
            need2[num[v]].pb(to);
    }
    int sz = g[v].size();
    for(int i = sz - 1; i >= 0; i--) {
        auto to = g[v][i];
        f_need3(to, c);
        if(cnt2[to] != 0)
            c.pb(to);
    }
    for(auto to : g[v]) {
        if(cnt2[to] != 0)
            c.pop_back();
    }
}

void f() {
    set <pair<int, int>> st;
    add(1, st);
    vector <int> t;
    t.pb(1);
    while(!st.empty()) {
        auto [mx, v] = *(--st.end());
        st.erase(--st.end());
        day[v] = t.size();
        t.pb(v);
        add(v, st);
    }
    for(int i = 0; i < n; i += sq) {
        for(int j = i; j < min(n, i + sq); j++) {
            num[t[j]] = j - i + 1;
            maxdel[t[j]] = max(maxdel[t[j]], res[t[j]]);
            us2[t[j]] = 1;
        }
        calc_cnt2(1);
        vector <int> c;
        f_need(1, c);
        f_need2(1, c);
        f_need3(1, c);
        for(int j = i; j < min(n, i + sq); j++) {
            maxdel[t[j]] = max(maxdel[t[j]], res[t[j]]);
            int id = j - i + 1;
            for(auto to : need2[id]) {
                maxdel[t[j]] = max(maxdel[t[j]], cnt[to] + add2[to]);
            }
            for(auto to : need[id]) {
                add2[to]++;
            }
        }

        for(int j = i; j < min(n, i + sq); j++) {
            int id = j - i + 1;
            for(auto to : need[id]) {
                add2[to]--;
            }
            need[id].clear();
            need2[id].clear();
        }
        for(int j = i; j < min(n, i + sq); j++) {
            us[t[j]] = 1;
            us2[t[j]] = 0;
            num[t[j]] = 0;
        }
        calc_cnt(1);
        calc_ans(1, 0);
    }
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // LOCAL
    int q;
    cin >> n >> q;
    //sq = sqrt(n);
    for(int i = 2; i <= n; i++) {
        cin >> p[i];
        g[p[i]].pb(i);
    }
    for(int i = 1; i <= n; i++) {
        cin >> s[i];
    }
    //dfs(1);
    f();
    while(q--) {
        int v;
        cin >> v;
        cout << day[v] - maxdel[v] << " ";
    }
}

