#include <bits/stdc++.h>
using namespace std;
#define int long long
const long long INF = 1e18, MOD = 1e9 + 7;

void solve();

vector <vector <int>> g;
vector <int> par;
vector <int> a;
vector <int> way;
int get(int v){
    way.push_back(par[v]);
    if (par[v] <= 0){
        return v;
    }
    return get(par[v]);
}
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, q;
    cin >> n >> q;
    g.resize(n);
    par.resize(n);
    par[0] = -1;
    for (int i = 1; i < n; i++){
        int p;
        cin >> p;
        p--;
        par[i] = p;
        g[p].push_back(i);
    }
    a.resize(n);
    vector <pair <int, int>> a1(n - 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i != 0) {
            a1[i - 1] = {a[i], i};
        }
    }
    vector <int> sz(n);
    set <pair <int, int>> st;
    st.insert({a[0], 0});
    int f = 0;
    while (!st.empty()){
        auto [c, v] = *st.rbegin();
        sz[v] = f;
        f++;
        st.erase(--st.end());
        for (auto x : g[v]){
            st.insert({a[x], x});
        }
    }
    sort(a1.rbegin(), a1.rend());
    vector <int> ans(n);
    set <pair <int, int>> us;
    vector <vector <pair <int, pair <int, int>>>> zap(n + 1);
    for (int i = 1; i < n; i++){
        way.clear();
        auto zz = get(i);
        int mn = a[i], pp = i;
        for (auto x : way){
            zap[mn].push_back({x, {pp, i}});
            pp = x;
            mn = min(mn, a[x]);
        }
    }
    for (auto x : g[0]){
        us.insert({a[x], x});
    }
    vector <pair <int, pair <int, int>>> dp(n);
    vector <int> maaax(n);
    for (int i = 0; i < n - 1; i++){
        while (!us.empty() && (*us.rbegin()).first > a1[i].first){
            auto [c, v] = *us.rbegin();
            us.erase(--us.end());
            for (auto to : g[v]){
                us.insert({a[to], to});
            }
            int prr = 0;
            while (v != -1){
                dp[v].first++;
                if (prr > dp[v].second.first){
                    dp[v].second.second = dp[v].second.first;
                    dp[v].second.first = prr;
                }
                else if (prr >= dp[v].second.second){
                    dp[v].second.second = prr;
                }
                prr = dp[v].first;
                v = par[v];
            }
        }
        for (auto x : zap[a1[i].first]){
            if (dp[x.first].second.first == dp[x.second.first].first){
                maaax[x.second.second] = max(maaax[x.second.second], dp[x.first].second.second);
            }
            else{
                maaax[x.second.second] = max(maaax[x.second.second], dp[x.first].second.first);
            }
        }
    }
    while (q--){
        int v;
        cin >> v;
        v--;
        cout << sz[v] - maaax[v] << " ";
    }
}
