#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

vector<vector<int>> gr;
vector<int> p, s, qs, pr;
multiset<pair<int, int>> vs;

void build() {
    int n = p.size();
    vs.insert({s[0], 0});
    while (qs.size() < n) {
        auto elem = *(--vs.end());
        qs.push_back(elem.second);
        vs.erase(elem);
        for (auto to: gr[elem.second]) {
            vs.insert({s[to], to});
        }
    }
}

vector<int> ti, to;
int timer = 0;

void dfs(int v, int pp) {
    ti[v] = timer++;
    pr[v] = pp;
    for (auto t : gr[v]) {
        if (gr[v].size() > 1) {
            dfs(t, t);
        } else {
            dfs(t, pp);
        }
    }
    to[v] = timer++;
}

bool check(int v, int u) {
    return ti[v] <= ti[u] && to[v] >= to[u] || ti[v] >= ti[u] && to[v] <= to[u];
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, q;
    cin >> n >> q;
    p.resize(n);
    s.resize(n);
    gr.resize(n);
    pr.resize(n);
    for (int i = 0; i < n - 1; ++i) {
        cin >> p[i + 1];
        p[i + 1]--;
        gr[p[i + 1]].push_back(i + 1);
    }
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    build();
    ti.resize(n);
    to.resize(n);
    dfs(0, 0);
    vector<pair<int, int>> c(n);
    for (int i = 0; i < n; ++i) {
        if (gr[i].size() > 1) {
            c[i] = {gr[i][0], gr[i][1]};
        } else if (gr[i].size() == 1) {
            c[i] = {gr[i][0], -1};
        }
    }
    vector<int> cnt(n);
    vector<int> ans(n);
    for (int i = 0; i < n; ++i) {
        int res = 0;
        int v = qs[i];
        while (v) {
            v = pr[v];
            int u = p[v];
            cnt[v]++;
            if (cnt[v] > cnt[c[u].first]) {
                c[u] = {v, c[u].first};
            } else if (!check(v, c[u].first) && cnt[v] > cnt[c[u].second]) {
                c[u].second = v;
            }
            if (gr[u].size() > 1) {
                if (!check(v, c[u].first)) {
                    res = max(res, cnt[c[u].first]);
                } else {
                    res = max(res, cnt[c[u].second]);
                }
            }
            v = u;
        }
        ans[qs[i]] = i - res;

    }
    for (int i = 0; i < q; ++i) {
        int x;
        cin >> x;
        x--;
        cout << ans[x] << '\n';
    }
}
