#include <bits/stdc++.h>
using namespace std;


using ll = long long;
const ll inf = 1e18;

const int N = 3e5;

int n;
int sz[N];
int head[N], pos[N];
vector<int> g[N];

int tr[N * 4], mod[N * 4];

void apply(int node, int x) {
    tr[node] += x;
    mod[node] += x;
}
void push(int node) {
    apply(node << 1, mod[node]);
    apply(node << 1 | 1, mod[node]);
    mod[node] = 0;
}
void update(int ql, int qr, int node = 1, int l = 0, int r = n - 1) {
    if (r < ql || qr < l) return;
    if (ql <= l && r <= qr) {
        apply(node, 1);
        return;
    }
    int m = (l + r) / 2;
    push(node);
    update(ql, qr, node << 1, l, m);
    update(ql, qr, node << 1 | 1, m + 1, r);
    tr[node] = max(tr[node << 1], tr[node << 1 | 1]);
}
int get(int ql, int qr, int node = 1, int l = 0, int r = n - 1) {
    if (r < ql || qr < l) return 0;
    if (ql <= l && r <= qr) return tr[node];
    int m = (l + r) / 2;
    push(node);
    return max(get(ql, qr, node << 1, l, m), get(ql, qr, node << 1 | 1, m + 1, r));
}

int sizes(int u) {
    sz[u] = 1;
    for (auto to : g[u]) {
        sz[u] += sizes(to);
    }
    return sz[u];
}

int timer = 0;
void dfs(int u) {
    if (g[u].empty()) return;
    pos[u] = timer++;
    for (int i = 0; i < g[u].size(); ++i) {
        if (sz[g[u][i]] > sz[g[u][0]]) swap(g[u][i], g[u][0]);
    }
    head[g[u][0]] = head[u];
    dfs(g[u][0]);
    for (int i = 1; i < g[u].size(); ++i) {
        head[g[u][i]] = g[u][i];
        dfs(g[u][i]);
    }
}

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    int q;
    cin >> n >> q;
    vector<int> p(n, -1);
    for (int i = 1; i < n; ++i) {
        cin >> p[i];
        p[i]--;
        g[p[i]].push_back(i);
    }
    vector<int> s(n);
    for (auto& i : s) cin >> i, i = n - i;
    sizes(0);
    dfs(0);
    vector<int> ans(n);
    int num = 0;
    set<pair<int, int>> que;
    que.emplace(s[0], 0);
    while (que.size()) {
        int u = que.begin()->second;
        que.erase(que.begin());
        vector<pair<int, int>> segs;
        for (int v = u; v != -1; v = p[head[v]]) {
            segs.emplace_back(pos[head[u]], pos[u]);
        }
        reverse(segs.begin(), segs.end());
        int prv = 0;
        int mx = 0;
        for (auto [x, y] : segs) {
            mx = max(mx, get(prv, x - 1));
            prv = y + 1;
        }
        mx = max(mx, get(prv, n - 1));
        ans[u] = num++ - mx;
        for (auto [x, y] : segs) {
            update(x, y);
        }
        for (auto to : g[u]) que.emplace(s[to], to);
    }
    while (q--) {
        int v;
        cin >> v;
        --v;
        cout << ans[v] << ' ';
    }
}
