//author: лелутик :3
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <time.h>
#include <cmath>
#include <cassert>
#include <random>
#include <priority_queue>
using namespace std;
#define line cout << "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define ppb pop_back
#define sz(a) (int) a.size()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pii pair<int, int>
const int MAXN = 3e5 + 10;
int p[MAXN], s[MAXN];
vector<int> g[MAXN];
int num[MAXN];
int dp[MAXN];
int t = 1;


bool cmp(pii a, pii b) {
    return num[a.first] < num[b.first];
}


void solve() {
    int n, q;
    cin >> n >> q;
    p[0] = -1;
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        g[p[i]].pb(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    int cur = 0, cnt = 0;
    set<pii> smezh;
    for (auto &u : g[0]) {
        smezh.insert({s[u], u});
    }
    while (1) {
        num[cur] = cnt;
        cnt++;
        if (sz(smezh) == 0) {
            break;
        }
        auto it = --smezh.end();
        int v = it->second;
        smezh.erase(it);
        for (auto &u : g[v]) {
            smezh.insert({s[u], u});
        }
        cur = v;
    }
    vector<pii> tasks(q);
    for (int i = 0; i < q; i++) {
        cin >> tasks[i].first;
        tasks[i].first--;
        tasks[i].second = i;
    }
    sort(all(tasks), cmp);
    set<pii> st;
    set<pii> qq;
    qq.insert({0, 0});
    vector<int> ans(q);
    for (int i = 0; i < q; i++) {
        while (sz(qq) && qq.begin()->first < num[tasks[i].first]) {
            int v = qq.begin()->second;
            qq.erase(qq.begin());
            for (auto &u : g[v]) {
                qq.insert({num[u], u});
            }
            while (v != -1) {
                st.erase({dp[v], v});
                dp[v]++;
                st.insert({dp[v], v});
                v = p[v];
            }
        }
        int v = tasks[i].first;
        int val = 0;
        int from = v;
        v = p[v];
        while (v != -1) {
            st.erase({dp[v], v});
            if (sz(g[v]) > 1) {
                if (g[v][0] != from) {
                    val = max(val, dp[g[v][0]]);
                } else {
                    val = max(val, dp[g[v][1]]);
                }
            }
            from = v;
            v = p[v];
        }
        ans[tasks[i].second] = num[tasks[i].first] - val;
        while (v != -1) {
            st.insert({dp[v], v});
        }
    }
    for (int i = 0; i < q; i++) {
        cout << ans[i] << " ";
    }
    line;
}

signed main() {
    fast;


#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif


    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}