#include <bits/stdc++.h>

using namespace std;

vector<int> p, d, val, prior;
vector<vector<int>> v, bin;

void dfs(int x) {
    for (auto j : v[x]) {
        d[j] = d[x] + 1;
        dfs(j);
    }
}

int find(int x, int h) {
    for (int i = 19; i >= 0; i--) {
        if (d[bin[i][x]] >= h) {
            x = bin[i][x];
        }
    }
    return x;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    prior.resize(n);
    v.resize(n);
    val.resize(n);
    d.resize(n);
    bin.resize(20, vector<int> (n));
    for (int i = 1; i < n; i++) {
        int x;
        cin >> x;
        x--;
        bin[0][i] = x;
        v[x].push_back(i);
    }
    for (int i = 1; i < 20; i++) {
        for (int j = 0; j < n; j++) {
            bin[i][j] = bin[i - 1][bin[i - 1][j]];
        }
    }
    dfs(0);
    for (int i = 0; i < n; i++) {
        cin >> val[i];
    }
    set<pair<int, int>> s;
    s.insert({val[0], 0});
    while (!s.empty()) {
        auto it = s.end();
        it--;
        auto [val1, id1] = *it;
        s.erase(it);
        prior[id1] = p.size();
        p.push_back(id1);
        for (auto j : v[id1]) {
            s.insert({val[j], j});
        }
    }
    vector<int> cnt(n, 1), res(n);

    for (auto i : p) {
        while (s.lower_bound({d[i], -1}) != s.end()) {
            auto it = s.lower_bound({d[i], -1});
            s.erase(it);
            auto [val1, id1] = *it;
            val1 = find(id1, d[i]);
            if (val1 != id1) {
                cnt[val1] += cnt[id1];
            }
            res[prior[i]] = max(res[prior[i]], cnt[val1]);
        }
        s.insert({d[i], i});
    }
    for (int i = 1; i < n; i++) {
        res[i] = max(res[i], res[i - 1]);
    }
    for (int i = 0; i < q; i++) {
        int x;
        cin >> x;
        x--;
        cout << prior[x] - res[prior[x]] << ' ';
    }
}
