#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_equal<>, 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;
vector<vector<int>> kids;
vector<int> p, s;
vector<int> ans;
vector<int> dep;
void slow(){
    int res = inf;
    for(auto x : kids[0]){
        int vv = s[x];
        s[x] = 0;
        set<pair<int, int>> gg;
        int time = 0;
        gg.insert({s[0], 0});
        while(!gg.empty()){
            int v = gg.rbegin()->second;
            ans[v] = min(ans[v], time);
            time++;
            for(auto x : kids[v]){
                gg.insert({s[x], x});
            }
            gg.erase({s[v], v});
        }
        s[x] = vv;
    }
}
vector<int> tin, tout;
int t = 0;
void dfs(int v){
    tin[v] = t++;
    for(auto u : kids[v]){
        dep[u] = dep[v]+1;
        dfs(u);
    }
    tout[v] = t++;
}

vector<int> ord;
vector<int> where;

void initord(){
    set<pair<int, int>> gg;
    gg.insert({s[0], 0});
    while(!gg.empty()){
        int v = gg.rbegin()->second;
        ord.push_back(v);
        where[v] = ord.size()-1;
        for(auto x : kids[v]){
            gg.insert({s[x], x});
        }
        gg.erase({s[v], v});
    }
}
vector<int> glav;
void dfs2(int v, int p){
    glav[v] = p;
    if(v == 0){
        for(auto u : kids[v]){
            dfs2(u, u);
        }
    }else{
        for(auto u : kids[v]){
            dfs2(u, p);
        }
    }
}
void solve() {
    int q ;
    cin >> n >> q;
    p.assign(n, 0);
    p[0] = -1;
    kids.assign(n, {});
    for(int i = 1; i < n; ++i){
        cin >> p[i];
        p[i]--;
        kids[p[i]].push_back(i);
    }
    tin.assign(n ,0);
    tout.assign(n, 0);
    where.assign(n, 0);
    s.assign(n, 0);
    for(int i = 0; i < n; ++i){
        cin >> s[i];
    }
    ans.assign(n, inf);
    dep.assign(n, 0);
    dfs(0);
    initord();
    //glav.assign(n, 0);
    //dfs2(0, 0);

    while(q--){
        int d;
        cin >>d;
        d--;
        if(d == 0){
            cout << 0 << " ";
            continue;
        }
        int ans = where[d];
        vector<int> pr;
        for(int j = 1; j < where[d]; ++j){
            pr.push_back(tin[j]);
        }
        sort(all(pr));
        for(int x = 1; x < n; ++x){
            if(tin[d] >= tin[x] && tout[d] <= tout[x]){
                continue;
            }
            int cnt = 0;
            cnt = upper_bound(all(pr), tout[x]) - upper_bound(all(pr), tin[x]-1);
            ans = min(ans, where[d] - cnt);
        }
        cout << ans << " ";
    }
}

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