#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

//#pragma GCC optimize("Ofast, unroll-loops, fast-math, no-stack-protector, inline")
//#pragma GCC target("avx, avx2")

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define int long long

const ll INF = 1e18 + 228;
const ll mod = 1e9 + 7;
const ld eps = 1e-8;

random_device rd;
mt19937 rnd(rd() + 228 + 57 - 179);

vector<vector<int>> g;
vector<int> s, tin, tout, w, eil;

void dfs(int v) {
    tin[v] = eil.size();
    eil.push_back(v);
    for (auto i : g[v]) {
        dfs(i);
    }
    tout[v] = eil.size();
}

struct seg_tree{
    vector<int> t;
    seg_tree(int n) {
        t.resize(4 * n);
    }
    void upd(int v, int l, int r, int pos, int x) {
        if (l + 1 == r) {
            t[v] += x;
            return;
        }
        int m = (l + r) / 2;
        if (pos < m) upd(v * 2, l, m, pos, x);
        else upd(v * 2 + 1, m, r, pos, x);
        t[v] = t[v * 2] + t[v * 2 + 1];
    }
    int get(int v, int l, int r, int L, int R) {
        if (L <= l && r <= R) return t[v];
        if (R <= l || r <= L) return 0;
        int m = (l + r) / 2;
        return get(v * 2, l, m, L, R) + get(v * 2 + 1, m, r, L, R);
    }
};

void solve() {
    int n, q;
    cin >> n >> q;
    g.resize(n);
    s.resize(n);
    tin.resize(n);
    tout.resize(n);
    w.resize(n);
    vector<int> hihi;
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        --p;
        g[p].push_back(i);
        if (p == 0) hihi.push_back(i);
    }
    for (int i = 0; i < n; ++i) cin >> s[i];
    vector<int> pos(n);
    set<pair<int, int>> st;
    st.emplace(0, 0);
    for (int i = 0; i < n; ++i) {
        auto [lvl, v] = *st.begin();
        st.erase(st.begin());
        w[i] = v;
        pos[v] = i;
        for (auto j : g[v]) {
            st.emplace(-s[j], j);
        }
    }
    dfs(0);
    vector<int> ans(n);
    seg_tree t(n);
    for (int i = 0; i < n; ++i) {
        int cur_d = i;
        int mx = 0;
        for (auto j : hihi) {
            if (tin[j] <= tin[w[i]] && tout[w[i]] <= tout[j]) continue;
            mx = max(mx, t.get(1, 0, n, tin[j], tout[j]));
        }
        ans[w[i]] = cur_d - mx;
        t.upd(1, 0, n, tin[w[i]], 1);
    }
    while (q--) {
        int v;
        cin >> v;
        --v;
        cout << ans[v] << ' ';
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int tt = 1;
    //cin >> tt;
    while (tt--) solve();
    return 0;
}
