#ifndef SEREGA
#include <bits/allocator.h>
#pragma GCC target("avx2,popcnt")
#pragma GCC optimize("O3,no-stack-protector")
#endif
#include <bits/stdc++.h>
using namespace std;
#define int int64_t

vector<vector<int>> g;
vector<int> s;
vector<int> v;
int n, q;

vector<int> path(1, 0);
vector<int> getindex;
vector<int> pref;
vector<int> col;
vector<int> answers;
vector<int> parent;

struct Node { 
    int index;
    int val;
};
const Node& max(const Node &l, const Node &r) {
    return l.val > r.val ? l : r;
}

struct Segtree {
    vector<Node> tree;
    void init(int n) {
        tree.assign(n * 2 - 1, {-1, 0});
        build(0, 0, n - 1);
    }
    void build(int x, int lx, int rx) {
        if (lx == rx) {
            tree[x] = {lx, 0};
            return;
        }
        int m = (lx + rx) >>1;
        build(x + 1, lx, m);
        build(x + 2 * (m - lx + 1), m + 1, rx);
        tree[x] = max(tree[x + 1], tree[x + 2 * (m - lx + 1)]);
    }
    Node get(int x, int lx, int rx, int l, int r) {
        if (l > r) return {-1, LLONG_MIN};
        if (l == lx && r == rx) return tree[x];
        int m = (lx + rx) >> 1;
        Node s1 = get(x + 1, lx, m, l, min(m, r));
        Node s2 = get(x + 2 * (m - lx + 1), m + 1, rx, max(m + 1, l), r);
        return max(s1, s2);
    }
    void add(int x, int lx, int rx, int i) {
        if (lx == rx) {
            tree[x].val++;
            return;
        }
        int mid = (lx + rx) >> 1;
        if (i <= mid) {
            add(x + 1, lx, mid, i);
        } else {
            add(x + 2 * (mid - lx + 1), mid + 1, rx, i);
        }
        tree[x] = max(tree[x + 1], tree[x + 2 * (mid - lx + 1)]);
    }
    int set(int x, int lx, int rx, int i, int v) {
        if (lx == rx) {
            int old = tree[x].val;
            tree[x].val = v;
            return old;
        }
        int mid = (lx + rx) >> 1;
        int val = 0;
        if (i <= mid) {
            val = set(x + 1, lx, mid, i, v);
        } else {
            val =  set(x + 2 * (mid - lx + 1), mid + 1, rx, i, v);
        }
        tree[x] = max(tree[x + 1], tree[x + 2 * (mid - lx + 1)]);
        return val;
    }
};

int getans(int v) {
    return answers[v];
}

int timer = 0;
void dfs(int x, int p) {
    parent[x] = p;
    for (int u : g[x]) {
        if (u != p) {
            dfs(u, x);
        }
    }
}
void bfs() { // nice bfs bro
    priority_queue<pair<int, int>, vector<pair<int, int>>, less<pair<int, int>>> q;
    q.push({s[1], 1});
    vector<int> used(n + 1);
    used[1] = 1;
    while (!q.empty()) {
        auto [_, v] = q.top();
        q.pop();

        getindex[v] = path.size();
        path.push_back(v);

        for (int u : g[v]) {
            if (!used[u]) {
                q.push({s[u], u});
                used[u] = 1;
            }
        }
    }
}
Segtree seg;
void solve() {
    cin >> n >> q;
    g.assign(n + 1, {});
    s.assign(n + 1, {});
    v.assign(q + 1, {});
    col.assign(n + 1, {});
    answers.assign(n + 1, {});
    getindex.assign(n + 1, {});
    parent.assign(n + 1, -1);
    
    for (int i = 0; i < n - 1; ++i) {
        int p;
        cin >> p;
        g[p].push_back(i + 2);
    }
    for (int i = 0; i < (int)g[1].size(); ++i) {
        dfs(g[1][i], 1);
    }
    for (int i = 1; i <= n; ++i) {
        cin >> s[i];
    }
    
    for (int i = 1; i <= q; ++i) {
        cin >> v[i];
    }
    bfs();
    pref.assign(path.size() + 1, {});
    seg.init(n + 1);
    for (int i = 2; i < (int)path.size(); ++i) {
        int v = path[i];
        // cout << "current index " << v << endl;
        // for (int i = 0; i <= n; ++i) {
        //     cout << seg.get(0, 0, n, i, i).val << ' ';
        // }
        // cout << endl;
        vector<int> deleted;
        int vv = v;
        while (vv != -1) {
            deleted.push_back(seg.set(0, 0, n, vv, 0));
            vv = parent[vv];
        }
        Node mx = seg.get(0, 0, n, 0, n);
        // cout << mx.index << ' ' << mx.val << endl;
        answers[v] = i - 1 - mx.val;
        int timer = 0;
        vv = v;
        while (vv != -1) {
            seg.set(0, 0, n, vv, deleted[timer++] + 1);
            vv = parent[vv];
        }
        // cout << "answer for that is " << answers[v] << endl;
    }
    for (int i = 1; i <= q; ++i) {
        if (v[i] == 1) {
            cout << 0 << endl;
            continue;
        }
        cout << getans(v[i]) << '\n';
    }

}

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