#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;

vector<vector<int>> g, ng;
vector<ll> a, b;
vector<int> dep, up, used, tin, tout;
vector<int> ord;

vector<ll> ans;
vector<int> req;

ll gay = 0;

void dfs(int v, int p) {
    dep[v] = (p == -1 ? 0 : dep[p] + 1);
    gay += 1;
    tin[v] = gay;
    if (p == -1) {
        up[v] = -1;
    }
    else {
        if (up[p] == -1) up[v] = v;
        else up[v] = up[p];
    }
    for (auto to : g[v]) {
        if (to != p) {
            dfs(to, v);
        }
    }
    gay++;
    tout[v] = gay;
}

int anc(int v,  int u) {
    return (tin[v] <= tin[u] && tout[v] >= tout[u]);
}

void make(int v) {
    used[v] = 1;
    ord.push_back(v);
    int mx = -1;
    for (auto to : g[v]) {
        if (!used[to] && (mx == -1 || a[to] > a[mx])) {
            mx = to;
        }
    }
    if (mx == -1) return;
    for (auto to : g[v]) {
        if (!used[to] && to != mx) {
            g[mx].push_back(to);
        }
    }
    g[v].clear();
    make(mx);
}

int f(int x, vector<int> y) {
    for (int i = 0; i < y.size(); i++) {
        if (y[i] == x) return i;
    }
    return -1;
}

void solve() {
    int n, q; cin >> n >> q;
    a.resize(n);
    b.resize(n);
    ng.resize(n);
    tin.resize(n), tout.resize(n);
    g.resize(n), used.resize(n), dep.resize(n), up.resize(n);
    for (int i = 2; i <= n; i++) {
        int p; cin >> p;
        g[p - 1].push_back(i - 1);
        g[i - 1].push_back(p - 1);

        ng[p - 1].push_back(i - 1);
        ng[i - 1].push_back(p - 1);
    }
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = a[i];
    }
    dfs(0, -1);
    req.resize(n, -1);
    ans.resize(q);
    make(0);
    for (int i = 0; i < q; i++) {
        ll v; cin >> v;
        v--;
        int pos = f(v, ord);
        int res = pos;
        for (int j = 1; j < pos; j++) {
            if (anc(ord[j], v)) continue;
            int sum = pos;
            for (int k = j; k < pos; k++) {
                if (anc(ord[j], ord[k])) sum--;
            }
            res = min(res, sum);
        }
        cout << res << ' ';
    }
}

int main() {
    int t = 1; //cin >> t;
    cin.tie(0);
    ios::sync_with_stdio(0);
    while (t--) {
        solve();
    }
}
