#pragma GCC optimize("O3,unroll-loops")
#include<bits/stdc++.h>
#pragma GCC target("avx,avx2,bmi,bmi2")

using namespace std;

#define all(x) (x).begin(),x.end()

#ifdef DBG
#define debug(x) cout << #x << " = " << x << endl
#else
#define debug(x) 
#endif

using ll = long long;

const int INF = 1e9;

mt19937 rnd(42);

struct SegTree {
    int n;
    vector<int> t;
    vector<int> p;

    int get(int i, int l, int r, int ql, int qr) {
        if (qr <= l || r <= ql) return -INF;

        if (ql <= l && r <= qr) return t[i];

        int mid = (l + r) / 2;
        return p[i] + max(get(i * 2 + 1, l, mid, ql, qr), get(i * 2 + 2, mid, r, ql, qr));
    }
    
    void add(int i, int l, int r, int ql, int qr, int x) {
        if (qr <= l || r <= ql) return;

        if (ql <= l && r <= qr) {
            t[i] += x;
            p[i] += x;
            return;
        }

        int mid = (l + r) / 2;
        add(i * 2 + 1, l, mid, ql, qr, x);
        add(i * 2 + 2, mid, r, ql, qr, x);

        t[i] = max(t[i * 2 + 1], t[i * 2 + 2]) + p[i];
    }

    void build(int i, int l, int r, vector<int>& v) {
        if (l + 1 == r) {
            t[i] = v[l];
            return;
        }

        int mid = (l + r) / 2;
        build(i * 2 + 1, l, mid, v);
        build(i * 2 + 2, mid, r, v);

        t[i] = p[i] + max(t[i * 2 + 1], t[i * 2 + 2]);
    }
    
    SegTree (vector<int> v) {
        n = v.size();
        t.assign(n * 4 + 10, 0);
        p.assign(n * 4 + 10, 0);
        build(0, 0, n, v);
    }

    void add(int l, int r, int x) {
        add(0, 0, n, l, r, x);
    }

    int get(int l, int r) {
        return get(0, 0, n, l, r);
    }
};

struct SegTreeSet {
    int n;
    vector<int> t;
    vector<map<int, int>> lv;

    void set(int i, int l, int r, int q, int x, int k) {
        if (q < l || r <= q) {
            return;
        }
        if (l + 1 == r) {
            if (lv[l].count(k) == 0) lv[l][k] = 0;
            lv[l][k] += x;
            t[i] = max(t[i], lv[l][k]);
            return;
        }

        int mid = (l + r) / 2;
        set(i * 2 + 1, l, mid, q, x, k);
        set(i * 2 + 2, mid, r, q, x, k);

        t[i] = max(t[i * 2 + 1], t[i * 2 + 2]);
    }

    int get(int i, int l, int r, int ql, int qr) {
        if (qr <= l || r <= ql) return 0;

        if (ql <= l && r <= qr) return t[i];

        int mid = (l + r) / 2;
        return max(get(i * 2 + 1, l, mid, ql, qr), get(i * 2 + 2, mid, r, ql, qr));
    }

    void build(int i, int l, int r, vector<int>& v) {
        if (l + 1 == r) {
            t[i] = v[l];
            return;
        }

        int mid = (l + r) / 2;
        build(i * 2 + 1, l, mid, v);
        build(i * 2 + 2, mid, r, v);

        t[i] = max(t[i * 2 + 1], t[i * 2 + 2]);
    }
    
    SegTreeSet (vector<int> v) {
        n = v.size();
        t.assign(n * 4 + 10, 0);
        lv.assign(n * 4 + 10, map<int, int>());
        build(0, 0, n, v);
    }

    void set(int i, int x, int k) {
        set(0, 0, n, i, x, k);
    }

    int get(int l, int r) {
        return get(0, 0, n, l, r);
    }
};


struct Tree {
    int n;
    vector<vector<int>> g;

    vector<int> sz;

    vector<int> p;

    void sz_dfs(int v, int p) {
        sz[v] = 1;
        int mxi = 0;
        for (int i = 0; i < g[v].size(); ++i) {
            int u = g[v][i];

            sz_dfs(u, v);
            if (sz[u] > sz[g[v][mxi]]) {
                mxi = i;
            }
        }

        if (mxi != 0) {
            swap(g[v][mxi], g[v][0]);
        }
    }

    SegTreeSet sts;
    SegTree sta;
    int timer = 0;
    vector<int> tin;
    vector<int> h;

    vector<map<int, int>> lv;
    vector<multiset<int>> lvs;

    void build_dfs(int v, int hd) {
        tin[v] = timer++;
        h[v] = hd;
        bool f = 1;
        for (int u : g[v]) {
            build_dfs(u, (f ? hd : u));
            f = 0;
        }
    }

    void add_on_path(int v, int x) {
        int pv = v;
        while (v >= 0) {
            int up = h[v];
            if (v != pv) {
                sts.set(tin[v], x, pv);
                debug(v << " " << pv);
                if (lv[v].count(pv)) {
                    lvs[v].erase(lvs[v].find(lv[v][pv]));
                } else {
                    lv[v][pv] = 0;
                }
                lv[v][pv] += x;
                lvs[v].insert(lv[v][pv]);
                debug(v << " " << pv);
            }
            sta.add(tin[up], tin[v] + 1, x);
            pv = up;
            v = p[up];
        }
    }

    ll get_on_path(int v) {
        int mx = 0;
        int pv = v;
        while (v >= 0) {
            int up = h[v];
            if (g[v].size() > 0) {
                mx = max(sta.get(tin[g[v][0]], tin[g[v][0]] + 1), mx);
            }
            mx = max(sts.get(tin[up], tin[v]), mx);
            debug(v << " " << mx);
            if (pv != v) {
                if (lv[v].count(pv)) {
                    int tmp = lv[v][pv];
                    lvs[v].erase(lvs[v].find(tmp));
                    if (lvs[v].size()) mx = max(*lvs[v].rbegin(), mx);
                    lvs[v].insert(tmp);
                } else if (lvs[v].size()) {
                    mx = max(*lvs[v].rbegin(), mx);
                }                
            }
            pv = up;
            v = p[up];
        }

        return mx;
    }

    Tree(vector<int> p_): n(p_.size() + 1), sta(vector<int>(p_.size() + 1, 0)), sts(vector<int>(p_.size() + 1, 0)) {
        p.assign(n, -1);
        g.assign(n, vector<int>());
        h.assign(n, -1);
        lvs.assign(n, multiset<int>());
        lv.assign(n, map<int, int>());
        for (int i = 0; i < n - 1; ++i) {
            p[i + 1] = p_[i];
        }
        sz.assign(n, 0);
        for (int i = 1; i < n; ++i) {
            g[p[i]].push_back(i);
        }
        sz_dfs(0, -1);
        tin.assign(n, 0);

        build_dfs(0, 0);
    }
};


inline void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> p(n - 1);
    for (int& i : p) {
        cin >> i;
        i--;
    }

    Tree t(p);

    vector<int> s(n);
    for (int& i : s) cin >> i;

    vector<int> res;
    set<pair<int, int>> pr;
    pr.insert({s[0], 0});
    while (pr.size()) {
        int v = pr.rbegin()->second;
        res.push_back(v);
        pr.erase(*pr.rbegin());
        for (int u : t.g[v]) {
            pr.insert({s[u], u});
        }
    }

    vector<int> ans(n, 0);

    for (int i = 0; i < n; ++i) {
        int v = res[i];
        ans[v] = i - t.get_on_path(v);

        t.add_on_path(v, 1);
    }

    for (int i = 0; i < q; ++i) {
        int v;
        cin >> v;
        v--;

        cout << ans[v] << endl;
    }
} 


int main() {
    int t = 1;
    #ifdef DBG
    cin >> t;
    #endif
    for (int i = 0; i < t; ++i) {
        solve();
        #ifdef DBG
        cout << '\n';
        #endif
    }
}