#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define len(x) (int)x.size()
#define all(x) x.begin(), x.end()
const ll INF = 1e18;
const int INFi = 1e9;

#ifndef LOCAL
const int N = 3e5 + 10;
#else
const int N = 5;
#endif

vector<int> g[N];
vector<int> sub[N];
int st[N], s[N], tin[N], tout[N];

int tim = 0;
void dfs(int v) {
    tin[v] = tim++;
    sub[v] = {st[v]};
    for (int to: g[v]) {
        dfs(to);
        for (auto x: sub[to]) {
            sub[v].push_back(x);
        }
    }
    sort(all(sub[v]));
    tout[v] = tim;
}

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

int check_dfs(int v, int from) {
    if (!an(v, from)) {
        int cnt = upper_bound(all(sub[v]), st[v]) - sub[v].begin();
        return cnt;
    }
    int ans = -INFi;
    for (int to: g[v]) {
        ans = max(ans, check_dfs(to, from));
    }
    return ans;
}

void solve() {
    int n, Q;
    cin >> n >> Q;
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        --p;
        g[p].push_back(i);
    }

    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }

    priority_queue<pair<int,int>> q;
    q.emplace(s[0], 0);
    int tmp = 0;
    while(!q.empty()) {
        auto [val, v] = q.top();
        q.pop();
        st[v] = tmp++;

        for (int to: g[v]) {
            q.emplace(s[to], to);
        }
    }

    dfs(0);

    for (int j = 0; j < Q; ++j) {
        int v;
        cin >> v;
        --v;
        if (!v) {
            cout << "0 ";
        } else {
            int ans = check_dfs(0, v);
            cout << st[v] - ans << ' ';
        }
    }

    cout << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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

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

    return 0;
}