#include <bits/stdc++.h>

#define int long long
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using namespace std;

const int N = 3e5 + 10;
const int inf = 1e18;

int par[N], cnt[N];
vector<int> g[N];

void add(int v, int x) {
    int cur = v;
    while (cur != -1) {
        cnt[cur] += x;
        cur = par[cur];
    }
}

void solve_case() {
    int n, q; cin >> n >> q;
    par[1] = -1;
    for (int i = 2; i <= n; i++) {
        cin >> par[i];
        g[par[i]].push_back(i);
    }
    vector<int> s(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
    }
    set<pair<int, int>> st;
    st.insert({s[1], 1});
    vector<int> d(n + 1), with(n);
    for (int i = 0; i < n; i++) {
        int v = st.rbegin()->second;
        st.erase(--st.end());
        d[v] = i;
        with[i] = v;
        for (int u : g[v]) {
            st.insert({s[u], u});
        }
    }
    // (d[v], v, i)
    vector<array<int, 3>> qs(q);
    for (int i = 0; i < q; i++) {
        int v; cin >> v;
        qs[i] = {d[v], v, i};
    }
    sort(all(qs));
    int ptr = 0;
    vector<int> ans(q);
    for (auto [_, v, id] : qs) {
        while (ptr < n && ptr < d[v]) {
            int u = with[ptr];
            add(u, 1);
            ptr++;
        }
        add(v, -inf);
        int mx = 0;
        for (int u = 1; u <= n; u++) {
            mx = max(mx, cnt[u]);
        }
        ans[id] = d[v] - mx;
        add(v, inf);
    }
    for (int i = 0; i < q; i++) {
        cout << ans[i] << ' ';
    }
    cout << '\n';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve_case();
    }
}