#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template<class T> using oset = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

//#define int long long
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
int inf = 1e9;
int n;
const int N = 3e5;
vector<int> kids[N];
int p[N], s[N];
int tin[N], tout[N];
int t = 0;
void dfs(int v){
    tin[v] = t++;
    for(auto u : kids[v]){
        dfs(u);
    }
    tout[v] = t++;
}

int ord[N];
int where[N];

void initord(){
    set<pair<int, int>> gg;
    gg.insert({s[0], 0});
    int time =0 ;
    while(!gg.empty()){
        int v = gg.rbegin()->second;
        ord[time] = v;
        where[v] = time;
        time++;
        for(auto x : kids[v]){
            gg.insert({s[x], x});
        }
        gg.erase({s[v], v});
    }
}

struct sgt{
    int n;
    vector<int> t;
    void build(int v, int l,int r, vector<int> &a){
        if(r-l == 1){
            if(l < a.size()){
                t[v] = a[l];
            }
            return;
        }
        int m=(l+r)/2;
        build(2*v+1, l, m, a);
        build(2*v+2, m, r, a);
        t[v] = max(t[2*v+1], t[2*v+2]);
    }
    sgt(vector<int> &a){
        n = 1;
        while(n < a.size()){
            n *= 2;
        }
        t.assign(2*n-1, 0);
        build(0, 0, n, a);
    }

    void upd(int v, int l, int r, int i){
        if(r-l == 1){
            t[v]++;
            return;
        }
        int m = (l+r)/2;
        if(i < m){
            upd(2*v+1, l, m, i);
        }else{
            upd(2*v+2, m, r, i);
        }
        t[v] = max(t[2*v+1], t[2*v+2]);
    }
    void upd(int i){
        upd(0, 0, n, i);
    }

    int get(int v, int l, int r, int lq, int rq){
        if(r <= lq || rq <= l){
            return 0;
        }
        if(l >= lq && r <= rq){
            return t[v];
        }
        int m = (l+r)/2;
        return max(get(2*v+1, l, m, lq, rq), get(2*v+2, m, r, lq, rq));
    }
    int get(int l, int r){
        if(l > r){
            return 0;
        }
        return get(0, 0, 0, l, r);
    }
};

void solve() {
    int q ;
    cin >> n >> q;
    p[0] = -1;
    for(int i = 1; i < n; ++i){
        cin >> p[i];
        p[i]--;
        kids[p[i]].push_back(i);
    }
    for(int i = 0; i < n; ++i){
        cin >> s[i];
    }
    dfs(0);
    initord();
    vector<int> ans(n);
    sgt tr(ans);
    for(int i = 1; i < 2; ++i){
        vector<int> preds;
        int u = ord[i];
        while(u != -1){
            preds.push_back(u);
            u = p[u];
        }
        sort(all(preds));
        int m = preds.size();
        int mx = 0;
        mx = max(mx, tr.get(0, preds[0]));
        mx = max(mx, tr.get(preds.back()+1, n));
        for(int i = 0; i+1 < m; ++i){
            mx = max(mx, tr.get(preds[i]+1, preds[i+1]));
        }
        ans[u] = i - mx;
        for(auto x : preds){
            tr.upd(x);
        }
    }
    while(q--){
        int d;
        cin >> d;
        d--;
        cout << ans[d] << " ";
    }
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt = 1;
    //cin >> tt;
    while(tt--){
        solve();
        cout << '\n';
    }
    return 0;
}
