#include <bits/stdc++.h>

using namespace std;

vector<vector<int>> g;
vector<int> s;
vector<int> pau;
vector<int> z;

void dfs(int v, int gl) {
    z[v] = gl;
    for (auto to : g[v]) {
        dfs(to, gl);
    }
}

void bfs() {
    set<pair<int, int>> q;
    q.insert({s[0], 0});
    int ind = 0;
    while (!q.empty()) {
        auto cur = q.rbegin();
        int v = cur->second;
        pau[ind++] = v;
        q.erase(*cur);
        for (auto to : g[v]) {
            q.insert({s[to], to});
        }
    }
}

void solve() {
    int n, q; cin >> n>> q;
    vector<int> p(n);
    s.resize(n);
    g.resize(n);
    pau.resize(n);
    z.resize(n);
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        g[p[i]].push_back(i);
    }
    for (auto& i : s) cin >> i;
    bfs();
    set<pair<int, int>> s;
    for (auto to : g[0]) {
        dfs(to, to);
        s.insert({0, to});
    }
    vector<int> k(n), ans(n);
    for (int i = 1; i < n; i++) {
        auto x = s.end();
        --x;
        //cout << pau[i] + 1 << ' ' << z[pau[i]] + 1 << ' ' << k[z[pau[i]]] << '\n';
        if (x->second == z[pau[i]]) {
            if (*x == *s.begin()) {
                ans[i] = i;
                continue;
            }
            --x;
        }
        //cout << x->first << ' ' << x->second + 1 << '\n';
        s.erase({k[z[pau[i]]]++, z[pau[i]]});
        s.insert({k[z[pau[i]]], z[pau[i]]});
        ans[pau[i]] = i - x->first;
    }
    while (q--) {
        int u; cin >> u; u--;
        cout << ans[u] << '\n';
    }
    cout << '\n';
}

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    solve();
}
