#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

vector<int> pos;

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

void dfs(int v, vector<vector<int>> &gr, vector<pair<int, int>> &answ, vector<int> &q) {
    int mx1 = 0;
    int mx2 = 0;
    for (auto x : gr[v]) {
        dfs(x, gr, answ, q);
        if (mx1 < q[x]) {
            mx2 = mx1;
            mx1 = q[x];
        } else if (mx2 < q[x]) {
            mx2 = q[x];
        }
    }
    answ[v].first = mx1;
    answ[v].second = mx2;
}
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, Q;
    cin >> n >> Q;
    vector<int> p(n);
    p[0] = 0;
    vector<vector<int>> gr(n);
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        gr[p[i]].push_back(i);
    }
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    set<pair<int, int>> ans;
    ans.insert({-s[0], 0});
    vector<int> vec;
    pos.resize(n);
    int j = 0;
    while (!ans.empty()) {
        pair<int, int> c = *ans.begin();
        ans.erase(c);
        pos[c.second] = j;
        j++;
        vec.push_back(c.second);
        for (auto x : gr[c.second]) {
            ans.insert({-s[x], x});
        }
    }
    set<pair<int, int>> st;
    vector<pair<int, int>> answ(n);
    vector<int> q(n);
    vector<int> answer(Q);
    vector<pair<int, int>> z(Q);
    for (int i = 0; i < Q; i++) {
        int v;
        cin >> v;
        v--;
        z[i].first = v;
        z[i].second = i;
    }
    sort(z.begin(), z.end(), &cmp);
    j = 0;
    for (int y = 0; y < Q; y++) {
        for (int i = j; i <= pos[z[y].first]; i++) {
            int v = vec[i];
            q[v]++;
            if (i == pos[z[y].first]) {
                int mx = 0;
                dfs(0, gr, answ, q);
                while (true) {
                    if (v == p[v]) {
                        break;
                    } else {
                        if (q[v] == answ[p[v]].first) {
                            mx = max(mx, answ[p[v]].second);
                        } else if (q[v] == answ[p[v]].second) {
                            mx = max(mx, answ[p[v]].first);
                        } else {
                            mx = max(mx, answ[p[v]].first);
                        }
                        v = p[v];
                    }
                }
                answer[z[y].second] = i - mx;
            }
        }
        j = pos[z[y].first] + 1;
    }
    for (auto x : answer) {
        cout << x << " ";
    }
}
