#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;
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});
    }
}
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();

    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[ord[j]]);
        }
        sort(all(pr));
        vector<int> need;
        for(int x = 1; x < n; ++x){
            if(tin[x] > tin[d] || tin[d] > tout[x]){
                need.push_back(x);
            }
        }
        for(auto x : need){
            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;
}
