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

#define f first
#define s second
#define pb push_back
#define pf push_front
#define in insert
#define nl '\n'
#define orderedSet tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update>

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

typedef long double ld;
typedef int64_t int64;
typedef uint64_t uint64;
typedef uint32_t uint;

using namespace std;
using namespace __gnu_pbds;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());

//#define int int64

const int N = 3e5 + 9;

bool b[N];
vector <int> v[N];
int n, q, p[N], s[N], numQ[N], ans[N], in[N], out[N], sum[N], tme, mx, qq;

void make(int x) {
    in[x] = tme;
    for (int u : v[x]) {
        ++tme;
        make(u);
    }
    out[x] = tme;
}

bool isPar(int a, int b) {
    return in[a] <= in[b] && out[b] <= out[a];
}

void dfs(int x) {
    if (!b[x])
        return;
    sum[x] = 1;
    for (int u : v[x]) {
        dfs(u);
        sum[x] += sum[u];
    }
    if (!isPar(x, qq))
        mx = max(mx, sum[x]);
}

main() {
    cin.tie(0); ios::sync_with_stdio(0); cout.tie(0);
    int n, q;
    cin >> n >> q;
    for (int i = 1; i < n; ++i) {
        cin >> p[i];
             --p[i];
        v[p[i]].pb(i);
    }
    make(0);
    for (int i = 0; i < n; ++i)
        cin >> s[i];
    set <pair <int, int>> st = {{s[0], 0}};
    vector <int> order;
    while (st.size()) {
        auto p = *(--st.end());
        st.erase(--st.end());
        order.pb(p.s);
        for (int u : v[p.s])
            st.in({s[u], u});
    }
    fill(numQ, numQ + q, -1);
    for (int i = 0; i < q; ++i) {
        int x;
        cin >> x;
             --x;
        numQ[x] = i;
    }
    for (int i = 0; i < n; ++i) {
        int u = order[i];
        b[u] = 1;
        if (numQ[u] > -1) {
            qq = u;
            mx = 0;
            dfs(0);
            ans[numQ[u]] = i - mx;
        }
    }
    for (int i = 0; i < q; ++i)
        cout << ans[i] << " ";
}
