#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <tuple>
#include <deque>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int INF = 2 * 1e9;
const ll MAX = 1e15;
const ll MIN = -1e15;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-7;

vector<vector<int>> g;
vector<int> s, cnt, euler;

bool cmp(int u, int v) {
    return s[u] > s[v];
}

int mx = 0;

int dfs(int u) {
    euler.push_back(u);
    cnt[u] = mx;
    int sz = 1;
    for (int v : g[u]) {
        sz += dfs(v);
    }
    mx = max(mx, sz);
    return sz + 1;
}

void solve() {
    int n, q; cin >> n >> q;
    g.assign(n, {});
    for (int u = 1; u < n; u++) {
        int p; cin >> p;
        p--;
        g[p].push_back(u);
    }
    s.assign(n, 0);
    for (int u = 0; u < n; u++) cin >> s[u];
    for (int u = 0; u < n; u++) {
        sort(g[u].begin(), g[u].end(), cmp);
    }
    cnt.assign(n, 0);
    dfs(0);
    vector<int> ok(n);
    for (int i = 0; i < n; i++) {
        ok[euler[i]] = i + 1;
    }
    while (q--) {
        int u; cin >> u;
        u--;
        int ans = ok[u] - max(1, cnt[u]);
        if (u == 0) cout << 0 << " ";
        else if (ans <= 0) cout << 1 << " ";
        else cout << ans << " ";
    }
}

signed main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int t = 1;
    //cin >> t;
    while (t--) solve();
}
