//#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;
vector<vector<int>> all;

void dfs(int v) {
    all[v].push_back(v);
    for (int i: g[v]) {
        dfs(i);
        for (int j: all[i]) {
            all[v].push_back(j);
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    g.resize(n);
    all.resize(n);
    s.resize(n);
    for (int i = 0; i < n - 1; ++i) {
        int p;
        cin >> p;
        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});
        }
    }
    dfs(0);
    vector<int> rev(n);
    for (int i = 0; i < n; ++i) {
        rev[ord[i]] = i;
    }
    while (m--) {
        int v;
        cin >> v;
        v--;
        int ans = rev[v];
        for (int i = 0; i < n; ++i) {
            int cnt = 0;
            bool e = 0;
            for (int j: all[i]) {
                if (rev[j] < rev[v]) {
                    cnt++;
                }
                if (j == v) {
                    e = 1;
                    break;
                }
            }
            if (!e) {
                ans = min(ans, rev[v] - cnt);
            }
        }
        cout << ans << '\n';
    }
    return 0;
}
//не забудь сохранять коды!!!