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

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

// #pragma GCC target("avx,avx2")

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 + 5;

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];
int t[N];

void add(int l) {
    for ( ; l < N; l |= l + 1) {
        t[l]++;
    }
}

int get(int r) {
    int res = 0;
    for ( ; r >= 0; r = (r & (r + 1)) - 1) {
        res += t[r];
    }
    return res;
}

int get(int l, int r) {
    return get(r) - get(l - 1);
}

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;
    }
    
    for (int i = 0; i < n; ++i) {
        if (off[i] != -1) {
            int que_it = off[i];
            int mna = i, ver = unsim[i];

            int uv = par[ver];
            while (1) {
                // for (auto& u: g[uv]) {/
                for (int j = 0; j < min(5, (int)g[uv].size()); ++j) {
                    int u = g[uv][j];
                    if (upper(u, ver)) continue;
                    int cnt = get(renum[u], renum[u] + sz[u] - 1);
                    mna = min(mna, i - cnt);
                }

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

            query[que_it] = mna;
        }

        add(renum[unsim[i]]);
    }

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

    return 0;
}
