#pragma GCC optimize("03")
#include <iostream>
#include <set>
#include <vector>
#include <random>
#include <iomanip>
//#include <fstream>
#include <algorithm>
#include <map>
#include <unordered_set>
#include <unordered_map>
#pragma GCC target("avx2")
const int INF = 1e7;
using namespace std;
vector<int> merge(vector<int>& a, vector<int>& b) {
    vector<int> ans;
    int l = 0, r = 0;
    while (l < a.size() and r < b.size()) {
        if (a[l] > b[r]) {
            ans.push_back(a[l++]);
        }
        else {
            ans.push_back(b[r++]);
        }
    }
    while (l < a.size()) {
        ans.push_back(a[l++]);
    }
    while (r < b.size()) {
        ans.push_back(b[r++]);
    }
    return ans;
}
vector<pair<int, int>> merge(vector<pair<int, int>>& a, vector<pair<int, int>>& b) {
    vector<pair<int, int>> ans;
    int l = 0, r = 0;
    while (l < a.size() and r < b.size()) {
        if (a[l] > b[r]) {
            ans.push_back(a[l++]);
        }
        else {
            ans.push_back(b[r++]);
        }
    }
    while (l < a.size()) {
        ans.push_back(a[l++]);
    }
    while (r < b.size()) {
        ans.push_back(b[r++]);
    }
    return ans;
}
void dfs(vector<vector<int>>& g, vector<int>& cost, vector<vector<int>>& mt, vector<int>& star, vector<int>& mv, vector<int>& h, int u, int p, int st) {
    mt[st].push_back(cost[u]);
    star[u] = st;
    mv[u] = min(mv[u], cost[u]);
    for (auto v : g[u]) {
        if (v == p) continue;
        mv[v] = mv[u];
        h[v] = h[u] + 1;
        dfs(g, cost, mt, star, mv, h, v, u, st);
    }
}
vector<int> get_pm(vector<int>& mt) {
    if (mt.empty()) return {};
    vector<int> pm;
    pm.push_back(mt[0]);
    for (int i = 1; i < mt.size(); i++) {
        pm.push_back(min(pm.back(), mt[i]));
    }
    return pm;
}
int gt_ans(vector<int>& pm, int mnv) {
    if (pm.empty()) return -1;
    int l = -1, r = pm.size();
    while (l + 1 < r) {
        int mid = (l + r) / 2;
        if (pm[mid] > mnv) {
            l = mid;
        }
        else {
            r = mid;
        }
    }
    return l;
}
signed main()
{
    cin.tie(nullptr)->sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    vector<vector<int>> g(n);
    vector<int> p(n, -1);
    for (int i = 1; i < n; i++) {
        int pr;
        cin >> pr;
        pr--;
        g[pr].push_back(i);
        p[i] = pr;
    }
    vector<int> cost(n);
    for (int i = 0; i < n; i++) {
        cin >> cost[i];
    }
    vector<int> gd;
    vector<bool> good(n);
    vector<vector<int>> mt(n);
    vector<vector<int>> pm(n);
    int C = 300;
    int Z = gd.size() / C + 60;
    vector<vector<pair<int, int>>> add(Z);
    vector<vector<int>> add2(Z);
    unordered_map<int, vector<int>> ids;
    unordered_map<int, int> col;
    vector<int> mxvs;
    vector<int> h(n);
    vector<int> mv(n, INF);
    vector<int> star(n);
    int nw = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] == 0) {
            gd.push_back(i);
            good[i] = true;
            dfs(g, cost, mt, star, mv, h, i, 0, i);
            col[i] = nw / C;
            ids[nw / C].push_back(i);
            pm[i] = get_pm(mt[i]);
            vector<pair<int, int>> mt2;
            for (auto j : mt[i]) {
                mt2.push_back({ j, nw % C });
            }
            add[nw / C] = merge(add[nw / C], mt2);
            nw++;
        }
    }
    vector<vector<vector<int>>> pref(Z, vector<vector<int>>(C));
    vector<vector<int>> mxx(Z, vector<int>());
    for (int i = 0; i < Z; i++) {
        if (add[i].empty()) continue;
        add2[i].push_back(add[i][0].first);
        mxx[i].resize(add[i].size());
        for (int j = 0; j < C; j++) {
            pref[i][j].resize(add[i].size());
        }
        pref[i][add[i][0].second][0] = 1;
        mxx[i][0] = 1;
        for (int j = 1; j < add[i].size(); j++) {
            add2[i].push_back(min(add2[i].back(), add[i][j].first));
            pref[i][add[i][j].second][j] = 1;
            int mxv = 0;
            for (int k = 0; k < C; k++) {
                pref[i][k][j] += pref[i][k][j - 1];
                mxv = max(mxv, pref[i][k][j]);
            }
            mxx[i][j] = mxv;
        }

    }
    while (q--) {
        int v;
        cin >> v;
        v--;
        int ans = h[v] + 1;
        if (v == 0) {
            cout << 0 << ' ';
            continue;
        }
        int mnv = mv[v];
        v = star[v];
        int mxv = 0;
        for (auto u : ids[col[v]]) {
            if (u == v) continue;
            int val = gt_ans(pm[u], mnv) + 1;
            mxv = max(mxv, val);
            ans += val;
        }
        for (int u = 0; u < Z; u++) {
            if (col[v] == u or add[u].empty()) continue;
            int l = gt_ans(add2[u], mnv);
            if (l == -1) continue;
            ans += l + 1;
            mxv = max(mxv, mxx[u][l]);
        }
        cout << ans - mxv << " ";
    }
}