#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

mt19937 rnd(69); // chrono::steady_clock::now().time_since_epoch().count()
#define all(x) x.begin(), x.end()
// #define int long long
#define ull unsigned long long
#define ld long double
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2")

const long long INF = 1e15 + 69;
const int MAXN = 2e5 + 11;

vector<vector<int>> graph;
int p[MAXN];
vector<int> s;
vector<int> tin;
vector<int> tout;
vector<int> ans_source;
vector<int> ans_for_q;
vector<int> first_non_zero;
vector<int> cur_ans;
vector<int> min_path;
int cur_t = 0;
int ans;

vector<pair<int, int>> scanline = {};

void dfs_precalc(int v, int p) {
    tin[v] = cur_t++;
    if (first_non_zero[p]) {
        first_non_zero[v] = first_non_zero[p];
    } else {
        first_non_zero[v] = v;
    }
    cur_ans[v] = 1;
    for (auto u : graph[v]) {
        if (u != p) {
            min_path[u] = s[u];
            if (v) {
                min_path[u] = min(min_path[u], min_path[v]);
            }
            dfs_precalc(u, v);
            cur_ans[v] += cur_ans[u];
        }
    }
    scanline.push_back({min_path[v], v});
    tout[v] = cur_t++;
}

bool is_ancestor(int v, int u) {
    return (tin[v] <= tin[u] && tout[v] >= tout[u]);
}

bool cmp(int v, int u) {
    return s[v] > s[u];
}

int dfs_calc_subtree(int v, int min_q) {
    int cur_ans = 1;
    for (auto u : graph[v]) {
        if (u != p[v] && s[u] > min_q) {
            cur_ans += dfs_calc_subtree(u, min_q);
        }
    }
    ans = max(ans, cur_ans);
    return cur_ans;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    int n, q, v;
    cin >> n >> q;
    graph.resize(n);
    tin.resize(n);
    tout.resize(n);
    s.resize(n);
    cur_ans.resize(n, 0);
    first_non_zero.resize(n, 0);
    ans_for_q.resize(n, 0);
    min_path.resize(n, n);
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        graph[p[i]].push_back(i);
    }
    p[0] = -1;
    set<pair<int, int>> first_dfs;
    first_dfs.insert({s[0], 0});
    cur_t = 0;
    ans_source.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        s[i]--;
    }
    cur_t = 0;
    dfs_precalc(0, 0);
    cur_t = 0;
    set<pair<int, int>> cur_max = {};
    vector<int> cur_sub_active(n, 0);
    while (first_dfs.size()) {
        v = (*(--first_dfs.end())).second;
        first_dfs.erase(--first_dfs.end());
        for (auto u : graph[v]) {
            first_dfs.insert({s[u], u});
        }
        ans_source[v] = cur_t++;
    }
    sort(all(scanline));
    set<pair<int, int>> cur_v = {};
    for (auto u : graph[0]) {
        cur_v.insert({cur_ans[u], u});
    }
    for (auto [garbage, v] : scanline) {
        if (!v) {
            continue;
        }
        int u = first_non_zero[v];
        cur_v.erase({cur_ans[u], u});
        cur_ans[u]--;
        if (cur_v.size()) {
            ans_for_q[v] = (*cur_v.begin()).first;
        }
        cur_v.insert({cur_ans[u], u});
    }
    for (int i = 0; i < q; i++) {
        cin >> v;
        v--;
        cout << ans_source[v] - ans_for_q[v] << " ";
    }
    return 0;
}
