#include <bits/stdc++.h>

#define int long long
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using namespace std;

const int N = 3e5 + 10;
const int inf = 1e18;

int par[N], sz[N], head[N], tin[N], tout[N], timer = 0;
vector<int> g[N];

void sizes(int v) {
    sz[v] = 1;
    for (int u : g[v]) {
        sizes(u);
        sz[v] += sz[u];
    }
}

void dfs(int v) {
    for (int &u : g[v]) {
        if (sz[u] > sz[g[v][0]]) {
            swap(u, g[v][0]);
        }
    }
    for (int u : g[v]) {
        dfs(u);
    }
}

void hld(int v) {
    tin[v] = timer++;
    for (int u : g[v]) {
        head[u] = (g[v][0] == u ? head[v] : u);
        hld(u);
    }
    tout[v] = timer;
}

struct SegTree {
    int n;
    vector<int> t, md;
    SegTree(int _n = 0) : n(_n), t(4 * n), md(4 * n) {}
    void push(int v) {
        if (md[v] == 0) {
            return;
        }
        t[2 * v] += md[v];
        md[2 * v] += md[v];
        t[2 * v + 1] += md[v];
        md[2 * v + 1] += md[v];
        md[v] = 0;
    }
    void add(int v, int l, int r, int ql, int qr, int x) {
        if (r < ql || qr < l) {
            return;
        }
        if (ql <= l && r <= qr) {
            t[v] += x;
            md[v] += x;
            return;
        }
        push(v);
        int mid = (l + r) / 2;
        add(2 * v, l, mid, ql, qr, x);
        add(2 * v + 1, mid + 1, r, ql, qr, x);
        t[v] = max(t[2 * v], t[2 * v + 1]);
    }
    void add(int l, int r, int x) {
        add(1, 0, n - 1, l, r, x);
    }
    int get() {
        return t[1];
    }
} st;

void add_path(int v, int x) {
    while (v != -1) {
        st.add(tin[head[v]], tin[v], x);
        v = par[head[v]];
    }
}

void solve_case() {
    int n, q; cin >> n >> q;
    par[1] = -1;
    for (int i = 2; i <= n; i++) {
        cin >> par[i];
        g[par[i]].push_back(i);
    }
    sizes(1);
    dfs(1);
    head[1] = 1;
    hld(1);
    vector<int> s(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
    }
    vector<int> d(n + 1), with(n);
    {
        set<pair<int, int>> qq;
        qq.insert({s[1], 1});
        for (int i = 0; i < n; i++) {
            int v = qq.rbegin()->second;
            qq.erase(--qq.end());
            d[v] = i;
            with[i] = v;
            for (int u: g[v]) {
                qq.insert({s[u], u});
            }
        }
    }
    // (d[v], v, i)
    vector<array<int, 3>> qs(q);
    for (int i = 0; i < q; i++) {
        int v; cin >> v;
        qs[i] = {d[v], v, i};
    }
    sort(all(qs));
    int ptr = 0;
    vector<int> ans(q);
    st = SegTree(n);
    for (auto [_, v, id] : qs) {
        while (ptr < n && ptr < d[v]) {
            int u = with[ptr];
            add_path(u, 1);
            ptr++;
        }
        add_path(v, -inf);
        ans[id] = d[v] - max(0ll, st.get());
        add_path(v, inf);
    }
    for (int i = 0; i < q; i++) {
        cout << ans[i] << ' ';
    }
    cout << '\n';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve_case();
    }
}