#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef long long ll;

void solve();

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int tt = 1; //cin >> tt;
    while (tt--) {
        solve();
        cout << "\n";
    }
}

const int N = 3e5 + 1;

struct Tree{
    int n;
    vector<int> t;

    Tree(int n) : n(n) {
        t.resize(4 * n);
    }

    void update(int p, int l, int r, int pos, int val) {
        if (pos < l || r <= pos) return;
        if (l + 1 == r) {
            t[p] += val;
            return;
        }
        int m = (l + r) / 2;
        update(2 * p + 1, l, m, pos, val);
        update(2 * p + 2, m, r, pos, val);
        t[p] = max(t[2 * p + 1], t[2 * p + 2]);
    }
    void update(int pos, int val) {
        update(0, 0, n, pos, val);
    }

    void set(int p, int l, int r, int pos, int val) {
        if (pos < l || r <= pos) return;
        if (l + 1 == r) {
            t[p] = val;
            return;
        }
        int m = (l + r) / 2;
        set(2 * p + 1, l, m, pos, val);
        set(2 * p + 2, m, r, pos, val);
        t[p] = max(t[2 * p + 1], t[2 * p + 2]);
    }
    void set(int pos, int val) {
        set(0, 0, n, pos, val);
    }

    int get(int p, int l, int r, int ql, int qr) {
        if (r <= ql || qr <= l) return 0;
        if (ql <= l && r <= qr) return t[p];
        int m = (l + r) / 2;
        return max(get(2 * p + 1, l, m, ql, qr), get(2 * p + 2, m, r, ql, qr));
    }
    int get(int l, int r) {
        return get(0, 0, n, l, r + 1);
    }
};

vector<int> g[N];
int tin[N], tout[N], s[N], p[N], pos[N], r[N], p2[N], add[N], t = 0;
vector<int> order;
set<pair<int, int> > c;

void dfs(int v) {
    tin[v] = t++;
    for (auto u : g[v]) dfs(u);
    tout[v] = t++;
}

bool ancestor(int a, int b) {
    return (tin[a] <= tin[b] && tout[b] <= tout[a]);
}

void find_order(int v) {
    order.push_back(v);

    for (auto u : g[v]) c.insert({-s[u], u});

    if (c.empty()) return;

    int best = (*c.begin()).S;
    c.erase(c.begin());

    find_order(best);
}

bool comp(pair<int, int> a, pair<int, int> b) {
    return pos[a.F] < pos[b.F];
}

void dfs2(int v, int p1 = -1) {
    p2[v] = p1;
    for (auto u : g[v]) {
        if (g[v].size() > 1) dfs2(u, u);
        else dfs2(u, p1);
    }
}


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

    dfs(0);
    find_order(0);
    dfs2(0);
    for (int i = 0; i < n; i++) pos[order[i]] = i;

    vector<pair<int, int> > v(q);
    vector<int> ans(q);
    for (int i = 0; i < q; i++) {
        cin >> v[i].F;
        v[i].F--;
        v[i].S = i;
    }
    sort(all(v), comp);

    Tree suf(n);
    int last = 0;
    for (int i = 0; i < q; i++) {
        set<int> all;
        for (int j = last; j < pos[v[i].F]; j++) {
            int x = order[j];
            x = p2[x];
            add[x]++;
            all.insert(x);
        }

        for (auto x : all) {
            int sum = 0;
            if (add[x] > 0) {
                while (x > 0) {
                    sum += add[x];
                    add[x] = 0;
                    suf.update(x, sum);
                    x = p[x];
                }
            }

        }

        int x = v[i].F;
        x = p2[x];
        while (x > 0) {
            r[x] = suf.get(x, x);
            suf.set(x, 0);
            x = p[x];
        }

        last = pos[v[i].F];
        ans[v[i].S] = pos[v[i].F] - suf.get(0, n - 1);

        x = v[i].F;
        x = p2[x];
        while (x > 0) {
            suf.set(x, r[x]);
            x = p[x];
        }
    }

    for (int i = 0; i < q; i++) cout << ans[i] << " ";
}
