#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

// #define int long long

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)((x).size()))

using ll = long long;
using ld = long double;

const ll INF = 3e18;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int N = 3e5 + 31;

vector<int> g[N];
int s[N];
int par[N];
int xz[N];
int mxpermin[N];
int smpermin[N];
int depth[N];
void solve() {
    int n;
    cin >> n;
    int q;
    cin >> q;
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        --p;
        par[i] = p;
        g[p].push_back(i);
        depth[i] = depth[p] + 1;
    }
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        --s[i];
    }
    vector<pair<int, int>> p;
    for (int i = 0; i < n; ++i) {
        p.push_back({s[i], i});
    }
    sort(rall(p));
    for (auto [val, v] : p) {
        if (v == 0)
            continue;
        smpermin[v] = depth[v];
        int vv = v;
        while (v && s[v] >= s[vv]) {
            xz[v]++;
            int r = par[v];
            for (int u : g[r]) {
                if (u == v)
                    continue;
                smpermin[vv] += xz[u];
                mxpermin[vv] = max(mxpermin[vv], xz[u]);
            }
            v = r;
        }
    }
    for (int i = 0; i < q; ++i) {
        int v;
        cin >> v;
        --v;
        if (v == 0) {
            cout << 0 << ' ';
            continue;
        }
        int sm = 0, mx = 0;
        int mnv = -1;
        while (v) {
            if (mnv == -1 || s[v] < s[mnv]) {
                mnv = v;
                sm += smpermin[mnv];
                mx = max(mx, mxpermin[mnv]);
            }

            v = par[v];
        }
        cout << sm - mx << ' ';
    }
}

signed main() {
#ifdef LOCALEGOR
    freopen("INPUT.txt", "r", stdin);
#else
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
    int tt = 1;
    // cin >> tt;
    while (tt--) {
        solve();
    }
}