#include<iostream>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<random>
#include<chrono>

using namespace std;

#pragma GCC optimize("O3")

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// #define int long long

const int MAX = 3e5 + 1;
vector<int> g[MAX];
int pos[MAX], son[MAX], val[MAX];
// vector<int> pos, son, val;


bool cmp(pair<int, int> a, pair<int, int> b) {
    return pos[a.first] < pos[b.first];
}

void dfs(int v, int p, int s) {
    if (p == 0) {
        s = v;
    }
    son[v] = s;
    for (auto u : g[v]) {
        if (u != p) {
            dfs(u, v, s);
        }
    }
}

signed main() {
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // cout.precision(20);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> p(n, -1);
    for (int i = 0; i < n - 1; ++i) {
        int x;
        cin >> x;
        x--;
        p[i + 1] = x;
        g[x].push_back(i + 1);
    }
    for (int i = 0; i < n; i++) {
        cin >> val[i];
    }
    dfs(0, 0, -1);
    multiset<pair<int, int>> st;
    st.insert({val[0], 0});
    vector<int> all;
    while (!st.empty()) {
        int v = (*st.rbegin()).second;
        // cout << v << endl;
        st.erase(st.find(*st.rbegin()));
        all.push_back(v);
        pos[v] = (int)all.size() - 1;
        for (auto u : g[v]) {
            st.insert({val[u], u});
        }
    }
    // cout << 1 << endl;
    vector<int> timer(n, -1);
    for (int i = 0; i < q; i++) {
        int num;
        cin >> num;
        timer[num - 1] = i;
    }
    vector<int> ans(q, 0);
    vector<int> cur(n, 0);
    int now = 0;
    for (int i = 1; i < n; i++) {
        if (timer[all[i]] != -1) {
            int mx = 0;
            int c_ai = all[i], prev = -1;
            while (c_ai != -1) {
                for (auto u : g[c_ai]) {
                    if (u != prev) {
                        mx = max(mx, cur[u]);
                    }
                }
                prev = c_ai;
                c_ai = p[c_ai];
            }
            ans[timer[all[i]]] = i - mx;
        }
        while (all[i] != -1) {
            cur[all[i]]++;
            all[i] = p[all[i]];
        }
    }
    for (auto u : ans) {
        cout << u << ' ';
    }
    cout << '\n';
}
