#include <bits/stdc++.h>
using namespace std;
#define int long long
//#pragma GCC optimize("O3,unroll-loops")

template<typename T>
istream& operator>>(istream& in, vector<T>& v) {
    for (T& i : v) in >> i;
    return in;
}

const int maxn = 300005;
vector<int> g[maxn];
int s[maxn];
int tin[maxn], tout[maxn];
int p[maxn];

int timer = 1;
vector<int> tinv = {-1};
void dfs(int v) {
    tinv.push_back(v);
    tin[v] = timer++;
    for (int u : g[v])
        dfs(u);
    tout[v] = timer;
}

int fenw[maxn];

void add(int i, int x) {
    for(; i < maxn; i += i & -i)
        fenw[i] += x;
}

int get(int i) {
    int res = 0;
    for (; i > 0; i -= i & -i)
        res += fenw[i];
    return res;
}

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

    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    set<pair<int, int>> child;
    child.insert({-s[0], 0});
    vector<int> vec;

    while (!child.empty()) {
        auto [u, v] = *child.begin();
        child.erase(child.begin());
        for (int t : g[v]) {
            child.insert({-s[t], t});
        }
        vec.push_back(v);
    }

    vector<int> pos(n);
    for (int i = 0; i < n; i++) {
        pos[vec[i]] = i;
    }

    vector<vector<int>> e(n);

    vector<int> qs(q);
    for (int i = 0; i < q; i++) cin >> qs[i], qs[i]--;
    vector<int> p(q);
    iota(p.begin(), p.end(), 0ll);
    sort(p.begin(), p.end(), [&](int a, int b) {
        return pos[qs[a]] < pos[qs[b]];
    });
    vector<int> gans(qs);

    int j = 0;

    dfs(0);

    for (int i = 0; i < q; i++) {
        int v = qs[p[i]];
        int posv = pos[v];

        while (j <= posv) {
            add(tin[vec[j]], 1);
            j++;
        }

        int cans = posv;

//        for (int k = 0; k < n; k++) {
//            if (tin[k] <= tin[v] && tout[k] >= tout[v]) continue;
//            cans = min(cans, posv - get(tout[k] - 1) + get(tin[k] - 1));
//        }

        int w = p[v];
        int pr = v;
        while (w != -1) {
            for (int i : g[w]) {
                if (i == pr) continue;
                cans = min(cans, posv - get(tout[i] - 1) + get(tin[i] - 1));
            }
            
            pr = w;
            w = p[w];
        }

        gans[p[i]] = cans;
    }

    for (int i = 0; i < q; i++) {
        cout << gans[i] << '\n';
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//     cin >> t;
    while (t--)
        solve(), cout << '\n';
}
