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

using namespace __gnu_pbds;
using namespace std;
using ordered_set = tree<long long, null_type, less_equal<>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
using ld = long double;
using str = string;
#define all(a) a.begin(), a.end()
#define len(a) int(a.size())
#define pb push_back
#define pbb pop_back
#define vc vector
#define rev reverse
#define F first
#define S second
vector<vector<int>> g;
vector<int> p, ans, id, last, pos;
vector<bool> us;

vector<int> t, push;

void makepush(int v) {
    if (push[v] == 0) return;
    t[v * 2] += push[v], t[v * 2 + 1] += push[v];
    push[v * 2] += push[v], push[v * 2 + 1] += push[v];
    push[v] = 0;
}

void add(int v, int l, int r, int ql, int qr, int var) {
    if (qr <= l || r <= ql) return;
    if (ql <= l && r <= qr) {
        t[v] += var, push[v] += var;
        return;
    }
    makepush(v);
    int m = (l + r) / 2;
    add(v * 2, l, m, ql, qr, var);
    add(v * 2 + 1, m, r, ql, qr, var);
    t[v] = max(t[v * 2], t[v * 2 + 1]);
}

int get(int v, int l, int r, int ql, int qr) {
    if (qr <= l || r <= ql) return 0;
    if (ql <= l && r <= qr) return t[v];
    makepush(v);
    int m = (l + r) / 2;
    int v1 = get(v * 2, l, m, ql, qr);
    int v2 = get(v * 2 + 1, m, r, ql, qr);
    return max(v1, v2);
}

int n;

void process() {
    us[0] = true;
    map<int, int> mp;
    for (int u: g[0]) {
        mp[p[u]] = u;
    }
    add(1, 0, n, 0, 1, 1);
    while (!mp.empty()) {
        auto [level, v] = *mp.rbegin();
        mp.erase(level);
        us[v] = true;
        int r1 = last[v], l2 = pos[v] + 1;
        ans[v] = max(get(1, 0, n, 1, r1), get(1, 0, n, l2, n));
        id.pb(v);
        add(1, 0, n, r1, pos[v] + 1, 1);
        for (int u: g[v]) {
            if (!us[u]) {
                mp[p[u]] = u;
            }
        }
    }
}

vector<int> order;

void dfs(int v, int parent, int trp) {
    order.pb(v);
    pos[v] = len(order) - 1;
    if (parent == -1 || parent == 0) trp = v;
    last[v] = pos[trp];
    for (int u: g[v]) {
        if (u != parent) {
            dfs(u, v, trp);
        }
    }
}

signed main() {
    int q;
    cin >> n >> q;
    g.resize(n), p.resize(n), us.assign(n, false);
    ans.resize(n), pos.resize(n), last.resize(n);
    for (int i = 1; i < n; i++) {
        int par;
        cin >> par;
        g[par - 1].pb(i);
        g[i].pb(par - 1);
    }
    for (int i = 0; i < n; i++) cin >> p[i];
    dfs(0, -1, -1);
    t.resize(4 * n), push.resize(4 * n);
    process();
    vector<int> timing(n);
    for (int i = 0; i < len(id); i++) {
        timing[id[i]] = i + 1;
    }
    while (q--) {
        int v;
        cin >> v;
        v--;
        cout << timing[v] - ans[v] << "\n";
    }
    return 0;
}
