#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define str string
#define pb push_back
#define ins insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pii pair<int, int>
#define ff first
#define ss second
#define ld long double
#define sz(a) (int)a.size()
#define int ll

mt19937 rnd(1488);

vector<vector<int>> gr;
vector<int> s;
vector<int> tin;
vector<int> tout;
int t = 0;
set<pii> tec;
vector<int> dp;
vector<int> dp2;
vector<int> cnt;

void dfs2(int v){
    tin[v] = t++;
    for (auto u:gr[v]){
        dfs2(u);
    }
    tout[v] = t;
}

void dfs(int v){
    for (auto u:gr[v]){
        tec.ins({s[u], u});
    }
    if (sz(tec)){
        int u = (*tec.rbegin()).ss;
        tec.erase(*tec.rbegin());
        dp[u] = dp[v] + 1;
        dp2[dp[u]] = u;
        dfs(u);
    }
}

void upd(int v, int k){
    if (v){
        cnt[v]++;
    }
    if (v == k){
        return;
    }
    for (auto u:gr[v]){
        if (tin[u] <= tin[k] && tout[k] <= tout[u]){
            upd(u, k);
        }
    }
}

void solve(){
    int n, q;
    cin >> n >> q;
    gr.resize(n);
    for (int i = 1; i < n; i++){
        int pr;
        cin >> pr;
        --pr;
        gr[pr].pb(i);
    }
    s.resize(n);
    for (int i = 0; i < n; i++){
        cin >> s[i];
    }
    tin.resize(n);
    tout.resize(n);
    dp.resize(n);
    dp2.resize(n);
    cnt.resize(n);
    dfs2(0);
    dfs(0);
    vector<array<int, 3>> z(q);
    for (int i = 0; i < q; i++){
        int v;
        cin >> v;
        --v;
        z[i] = {dp[v], v, i};
    }
    int j = 0;
    sort(all(z));
    vector<int> ans(q);
    for (auto [i, v, ind]:z){
        while (j < i){
            upd(0, dp2[j++]);
        }
        int mx = 0;
        for (int k = 0; k < n; k++){
            if (tin[k] <= tin[v] && tout[v] <= tout[k]){
                continue;
            }
            mx = max(mx, cnt[k]);
        }
        ans[ind] = dp[v] - mx;
    }
    for (auto i:ans){
        cout << i << " ";
    }
}

int32_t main(){
    cin.tie(0)->ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif // LOCAL
    int _ = 1;
    //cin >> _;
    while (_--){
        solve();
    }
}
