#include<bits/stdc++.h>

using namespace std;

using ll = long long;

int lg = 18;
int n;

vector<vector<int>> g, up;
vector<int> s, d, tin, tout;

int t = 0;

void dfs(int v, int p) {
    tin[v] = t++;
    up[0][v] = p;
    if (v != 0)
        d[v] = min(d[p], s[v]); //считаем min предка
    for (int i = 1; i < lg; ++i)
        up[i][v] = up[i - 1][up[i - 1][v]];
    for (auto u : g[v]) {
        if (u == p) continue;
        dfs(u, v);
    }
    tout[v] = t++;
}

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

int get(int v) {
    int res = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] > s[v] && d[i] > s[v] && !pred(v, i) || pred(i, v)) {
            //cout << v + 1 << " " << i + 1 << endl;
            ++res;
        }
    }
    return max(res - 2, 0);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int q;
    cin >> n >> q;
    g.resize(n);
    tin.resize(n);
    tout.resize(n);
    up.resize(lg, vector<int> (n));
    s.resize(n);
    d.resize(n);

    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];
    d[0] = 1e6;
    dfs(0, 0);
    for (int i = 0; i < q; ++i) {
        int v;
        cin >> v;
        --v;
        cout << get(v) << " ";
    }
}

