#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;

void fast_in_out() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

#define int long long
#define all(x) (x).begin(), (x).end()
using ll = long long;
using ull = long long;
using ld = long double;
typedef tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 3e5;
int n, q, p[N], sup[N], s[N], ans[N], pos[N], sz[N];
vector<int> g[N], order;
multiset<int> t[N];

void dfs(int v = 0, int super = 0) {
    if ((int) g[p[p[v]]].size() >= 2) {
        super = p[v];
    }
    sup[v] = super;
    for (auto to: g[v]) {
        dfs(to, super);
    }
}

void add(int v) {
    sz[v]++;
    if (v == 0) {
        return;
    }
    t[p[v]].extract(sz[v] - 1);
    t[p[v]].insert(sz[v]);
    add(sup[v]);
}

int Ans(int v) {
    if (v == 0) {
        return 0;
    }
    int ANS = 0;
    if ((int) t[p[v]].size() != 1) {
        t[p[v]].extract(sz[v]);
        ANS = *(--t[p[v]].end());
        t[p[v]].insert(sz[v]);
    }
    return max(ANS, Ans(sup[v]));
}

void solve() {
    cin >> n >> q;
    for (int i = 1; i < n; ++i) {
        cin >> p[i];
        --p[i];
        g[p[i]].emplace_back(i);
        t[p[i]].insert(0);
    }
    dfs();
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    set<pair<int, int>> st;
    st.insert({s[0], 0});
    while (!st.empty()) {
        auto [d, v] = *(--st.end());
        st.erase(--st.end());
        order.emplace_back(v);
        pos[v] = (int) order.size() - 1;
        for (auto to: g[v]) {
            st.insert({s[to], to});
        }
    }
    for (auto v: order) {
        add(v);
        ans[v] = pos[v] - Ans(v);
    }
    while (q--) {
        int x;
        cin >> x;
        --x;
        cout << ans[x] << ' ';
    }
}

signed main() {
    fast_in_out();
    int qwe = 1;
//    cin >> qwe;
    while (qwe--) {
        solve();
    }
    return 0;
}
