#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
//#define int long long

const int N = 3e5 + 100;
vector<int> order, g[N];
int par[N], a[N], siz[N], up[N], timer = 1, tin[N], tout[N], val[N], ans[N], d[N * 4 + 1000], p[N * 4 + 1000];

void dfs(int v) {
    siz[v] = 1;
    for (int i = 0; i < sz(g[v]); ++i) {
        dfs(g[v][i]);
        if (siz[g[v][i]] > siz[g[v][0]]) {
            swap(g[v][i], g[v][0]);
        }
        siz[v] += siz[i];
    }
}

void hld(int v) {
    tin[v] = timer++;
    for (int i : g[v]) {
        if (i == g[v][0]) {
            up[i] = up[v];
        } else {
            up[i] = i;
        }
        hld(i);
    }
    val[tin[v]] = timer - tin[v];
    tout[v] = timer;
}

void build(int v, int l, int r) {
    if (l == r) {
        d[v] = val[l];
        return;
    }
    int m = (l + r) / 2;
    build(2 * v, l, m);
    build(2 * v + 1, m + 1, r);
    d[v] = max(d[2 * v], d[2 * v + 1]);
}

void push(int v) {
    if (p[v] != 0) {
        d[2 * v] += p[v];
        d[2 * v + 1] += p[v];
        p[2 * v] += p[v];
        p[2 * v + 1] += p[v];
        p[v] = 0;
    }
}

void update(int v, int l, int r, int x, int y, int zn) {
    if (l > y || x > r) {
        return;
    }
    if (l >= x && r <= y) {
        d[v] += zn;
        p[v] += zn;
        return;
    }
    push(v);
    int m = (l + r) / 2;
    update(2 * v, l, m, x, y, zn);
    update(2 * v + 1, m + 1, r, x, y, zn);
    d[v] = max(d[2 * v], d[2 * v + 1]);
}

vector<pair<int, int>> can;
int now;

int find_ans(int v, int l, int r) {
    while (now >= 0 && can[now].second < l) {
        now--;
    }
    if (now != -1 && can[now].first <= l && can[now].second >= r) {
        return 0;
    }
    if (now == -1 || can[now].first > r) {
        return d[v];
    }
    int m = (l + r) / 2;
    push(v);
    auto x = find_ans(2 * v, l, m);
    return max(x, find_ans(2 * v + 1, m + 1, r));
}

int n, q;

void upd(int v) {
    can.clear();
    while (v > 0) {
        update(1, 1, n, tin[up[v]], tin[v], -1);
        can.pb({tin[up[v]], tin[v]});
        v = par[up[v]];
    }
    now = sz(can) - 1;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> q;
    set<pair<int, int>> s;
    for (int i = 2; i <= n; ++i) {
        cin >> par[i];
        g[par[i]].pb(i);
    }
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    s.insert({-a[1], 1});
    while (!s.empty()) {
        auto [u, v] = *s.begin();
        s.erase(s.begin());
        order.pb(v);
        for (int j : g[v]) {
            s.insert({-a[j], j});
        }
    }
    dfs(1);
    up[1] = 1;
    hld(1);
    build(1, 1, n);
    for (int i = n - 1; i >= 0; --i) {
        upd(order[i]);
        int last = 1, tek = 0;
        tek = max(tek, find_ans(1, 1, n));
        ans[order[i]] = i - tek;
    }
    while (q--) {
        int x;
        cin >> x;
        cout << ans[x] << " ";
    }
    return 0;
}
