

#include <bits/stdc++.h>

using namespace std;

const int N = 3e5 + 12;
using ll = long long;
#define int long long
mt19937_64 rng (time (0));
int n, q;
int p[N], s[N];
int ans[N];
vector<int> g[N];
int depth[N], tin[N];
int t = 0;
int cur[N];
void calc () {
    set<pair<int,int>> st;
    for (auto to : g[1]) st.insert ({s[to], to});
    int ct = 0, root = 1;
    ans[1] = 0;
    while ((int)st.size()) {
        int nxt_root = (*st.rbegin()).second;
        st.erase (--st.end());
        ct += 1;
        for (auto to : g[nxt_root]) st.insert ({s[to], to});
        int was = nxt_root;
        int opt = 0;
        while (was != 1) {
            cur[was] += 1;
            int ww = was;
            was = p[was];
            for (auto to : g[was]) {
                if (to == ww) continue;
                opt = max (opt, cur[to]);
            }
        }
        root = nxt_root;
        ans[nxt_root] = ct - opt;
    }
}

signed main() {
//#ifdef local
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif // local
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> q;
    for (int i = 2; i <= n; ++i) {
        cin >> p[i];
        g[p[i]].push_back (i);
    }
    for (int i = 1; i <= n; ++i) {
        ans[i] = n;
        cin >> s[i];
    }
    calc ();
    while (q--) {
        int v;
        cin >> v;
        cout << ans[v] << ' ';
    }
    cout << '\n';
}
