#include <bits/stdc++.h>

#ifndef LOCAL
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

const int maxn = 3e5;
vector<int> g[maxn];
int s[maxn];
int ans[maxn];
int ans1[maxn];
int tin[maxn];
int tout[maxn];
int pr[maxn];
int h[maxn];
int sz[maxn];
int tk;
int n;
int tree[maxn << 2];
int diff[maxn << 2];

void add(int v, int l, int r, int ql, int qr) {
    if(ql <= l && r <= qr) {
        diff[v]++;
        tree[v]++;
        return;
    }
    if(qr <= l || r <= ql) {
        return;
    }
    int mid = (l + r) / 2;
    add(2 * v + 1, l, mid, ql, qr);
    add(2 * v + 2, mid, r, ql, qr);
    tree[v] = max(tree[2 * v + 1], tree[2 * v + 2]);
}

int get(int v, int l, int r, int ql, int qr) {
    if(ql <= l && r <= qr) {
        return tree[v];
    }
    if(qr <= l || r <= ql) {
        return 0;
    }
    int mid = (l + r) / 2;
    return max(get(2 * v + 1, l, mid, ql, qr), get(2 * v + 2, mid, r, ql, qr)) + diff[v];
}

bool is_pr(int a, int b) {
    return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int get_hld(int v) {
    vector<pair<int, int>> seg;
    while (v != -1) {
        seg.emplace_back(tin[h[v]], tin[v]);
        v = pr[h[v]];
    }
    sort(all(seg));
    int ans = 0;
    int pr = 0;
    for (auto [l, r]: seg) {
        if(l > pr)
            ans = max(ans, get(0, 0, n, pr, l));
        pr = r + 1;
    }
    if (n > pr) {
        ans = max(ans, get(0, 0, n, pr, n));
    }
    return ans;
}

void add_hld(int v) {
    while (v != -1) {
        add(0, 0, n, tin[h[v]], tin[v] + 1);
        v = pr[h[v]];
    }
}

void dfs0(int v) {
    sz[v] = 1;
    for(int i: g[v]) {
        dfs0(i);
        sz[i] += sz[v];
        pr[i] = v;
    }
    if(!g[v].empty()) {
        iter_swap(max_element(all(g[v]), [&](int a, int b) {
            return sz[a] < sz[b];
        }), g[v].begin());
    }
}

void dfs1(int v) {
    tin[v] = tk++;
    if(!g[v].empty()) {
        // h[g[v][0]] = h[v];
    }
    for(int i: g[v]) {
        dfs1(i);
    }
    tout[v] = tk;
}

void calc() {
    set<pair<int, int>> ch;
    ch.insert({0, 0});
    int tk = 0;
    while(!ch.empty()) {
        auto res = *ch.rbegin();
        ch.erase(res);
        int u = res.second;
        ans[u] = min(ans[u], tk++);
        for (int i: g[u]) {
            ch.emplace(s[i], i);
        }
    }
}

void solve() {
    fill(ans, ans + maxn, 1e9);
    iota(h, h + maxn, 0);
    int q;
    cin >> n >> q;
    for(int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        --p;
        g[p].push_back(i);
    }
    pr[0] = -1;
    for(int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    calc();
    dfs0(0);
    dfs1(0);
    vector<int> sup(n);
    for(int i = 0; i < n; ++i) {
        sup[ans[i]] = i;
    }
    for (int i: sup) {
        ans1[i] = ans[i] - get_hld(i);
        add_hld(i);
    }
    for(int i = 0; i < q; ++i) {
        int x;
        cin >> x;
        cout << ans1[x - 1] << ' ';
    }
}

signed main() {
#ifndef LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#else
    freopen("C:\\Users\\User\\aboab\\input.txt", "r", stdin);
#endif
    solve();
}