#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int maxn = 3e5 + 3, n, cnt = 0;
vector<vector<int>> g(maxn);
vector<int> s(maxn);

void dfs(int v, int x) {
    cnt++;
    for (int u : g[v]) {
        if (s[u] > s[x]) {
            dfs(u, x);
        }
    }
}



int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int q, v;
    cin >> n >> q;
    for (int i = 2; i <= n; i++) {
        cin >> v;
        g[v].push_back(i);
    }
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
    }
    for (int i = 1; i <= q; i++) {
        cin >> v;
        if (v == 1) {
            cout << 0 << ' ';
            continue;
        }
        cnt = 0;
        dfs(1, v);
        cout << cnt - 1 << ' ';
    }
}
