//#pragma GCC optimize("unroll-loops","Ofast")
//#pragma GCC target("sse","sse2","avx","avx2")
#include <bits/stdc++.h>

//#define int long long
#define F first
#define S second
using namespace std;
int n, m;
vector<vector<int>> g;
vector<int> s;
vector<int> ord;

struct query {
    int v, revv, id;
};

bool cmp(query a, query b) {
    return a.revv < b.revv;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    g.resize(n);
    s.resize(n);
    vector<int> ps(n, -1);
    for (int i = 0; i < n - 1; ++i) {
        int p;
        cin >> p;
        p--;
        ps[i + 1] = p;
        g[p].push_back(i + 1);
    }
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    set<pair<int, int>> ms;
    ms.insert({-s[0], 0});
    while (!ms.empty()) {
        int v = ms.begin()->S;
        ms.erase(ms.begin());
        ord.push_back(v);
        for (int i: g[v]) {
            ms.insert({-s[i], i});
        }
    }
    vector<int> rev(n);
    for (int i = 0; i < n; ++i) {
        rev[ord[i]] = i;
    }
    vector<query> qs(m);
    for (int i = 0; i < m; ++i) {
        cin >> qs[i].v;
        qs[i].v--;
        qs[i].revv = rev[qs[i].v];
        qs[i].id = i;
    }
    sort(qs.begin(), qs.end(), cmp);
    vector<int> cnt(n);
    vector<int> an(m);
    multiset<int> mxs;
    for (int i = 0; i < n; ++i) {
        mxs.insert(0);
    }
    mxs.insert(0);
    int idnow = 0;
    for (query i: qs) {
        while (idnow < i.revv) {
            int v = ord[idnow];
            while (v != -1) {
                mxs.erase(mxs.find(cnt[v]));
                cnt[v]++;
                mxs.insert(cnt[v]);
                v = ps[v];
            }
            idnow++;
        }
        int v = i.v;
        while (v != -1) {
            mxs.erase(mxs.find(cnt[v]));
            v = ps[v];
        }
        int ans = i.revv - *--mxs.end();
        an[i.id] = ans;
        v = i.v;
        while (v != -1) {
            mxs.insert(cnt[v]);
            v = ps[v];
        }
    }
    for (int i: an) {
        cout << i << " ";
    }
    return 0;
}
//не забудь сохранять коды!!!