#pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")

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

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 3e5 + 1;

int par[N], s[N];
vector<vector<int>> g(N);
int depth[N];

int num[N], renum[N];
int sim[N];
int unsim[N];

int timer = 0, iter = 1;
int sz[N], tin[N], tout[N];

void dfs(int v) {
    renum[v] = iter++;
    tin[v] = timer++;
    sz[v] = 1;
    for (auto& u: g[v]) {
        dfs(u);
        sz[v] += sz[u];
    }
    tout[v] = timer++;
}

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    int n, q;
    cin >> n >> q;

    for (int i = 2; i <= n; ++i) {
        cin >> par[i];
        g[par[i]].push_back(i);
    }

    for (int i = 1; i <= n; ++i) {
        cin >> s[i];
    }

    dfs(1);

    vector<set<pair<int, int>>> f(n + 1);
    for (int i = 1; i <= n; ++i) {
        num[i] = i;

        for (int j = 0; j < g[i].size(); ++j) {
            f[i].insert({-s[g[i][j]], g[i][j]});
        }
    }

    int root = 1, in = n;
    int day = 0;

    vector<int> que;
    while (in) {
        que.push_back(num[root]);
        sim[num[root]] = day;
        unsim[day] = num[root];
        --in, ++day;
            
        if (in == 0) break;
        pair<int, int> que = *f[root].begin();
        f[root].erase(f[root].begin());
        int next = que.second;

        if (f[next].size() < f[root].size()) {
            for (auto& u: f[next]) {
                f[root].insert(u);
            }
            num[root] = next;
        } else {
            for (auto& u: f[root]) {
                f[next].insert(u);
            }
            root = next;    
        }
    }

    vector<int> query(q);
    vector<int> off(n, -1);

    for (int i = 0; i < q; ++i) {
        int v;
        cin >> v;

        if (v == 1) {
            query[i] = 0;
            continue;
        }

        off[sim[v]] = i;
    }

    oset<int> st;
    for (int i = 0; i < n; ++i) {
        if (off[i] != -1) {
            int que_it = off[i];
            
            int mna = i, ver = unsim[i];

            vector<int> can;
            int uv = par[ver];
            while (1) {
                for (auto& u: g[uv]) {
                    if (upper(u, ver)) continue;
                    can.push_back(u);
                }

                if (uv == 1) break;
                uv = par[uv];
            }

            for (auto& j: can) {
                int cnt = st.order_of_key(renum[j] + sz[j]);
                cnt -= st.order_of_key(renum[j]);
                mna = min(mna, i - cnt);
            }

            query[que_it] = mna;
        }

        st.insert(renum[unsim[i]]);
    }

    for (int i = 0; i < q; ++i) {
        cout << query[i] << "\n";
    }

    return 0;
}
