#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <cstdint>
using namespace std;
#define int long long

void solution();

int32_t main() {
#ifdef LOCAL
    freopen("test", "r", stdin);
    freopen("out", "w", stdout);
#endif

    int t = 1;
    // cin >> t;
    while (t--) {
        solution();
    }
}

vector<vector<int>> gr;
vector<int> p, s, sz;
vector<int> ans0, ans1;

void calc_sz(int s) {
    sz[s] = 1;
    for (auto v : gr[s]) {
        calc_sz(v);
        sz[s] += sz[v];
    }
}

void solution() {
    int n, q;
    cin >> n >> q;

    p.resize(n);
    s.resize(n);

    gr.resize(n);
    for (int i = 1; i < n; ++i) {
        cin >> p[i];
        p[i]--;
        gr[p[i]].push_back(i);
    }

    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        s[i]--;
    }

    sz.resize(n);
    
    calc_sz(0);

    vector<int> pos(n);
    for (int i = 0; i < n; ++i) {
        pos[s[i]] = i;
    }

    ans0.resize(n);
    ans1.resize(n);
    for (auto i : pos) {
        if (i == 0) continue;
        int x = i;
        while (s[x] >= s[i] && x > 0) {
            x = p[x];
            sz[x] -= sz[i];
        }
        int first = x;
        ans0[i] = ans0[first] + sz[first];
        ans1[i] = ans1[first] + sz[first];
        
        x = i;
        int last;
        while (s[x] >= s[i] && x > 0) {
            last = x;
            x = p[x];
            for (auto v : gr[x]) {
                if (s[v] <= s[i] || v == last) continue;
                ans1[i] = min(ans1[i], ans0[first] + sz[first] - sz[v]);
            }
        }
    }

    while (q--) {
        int x;
        cin >> x;
        x--;
        cout << ans1[x] << ' ';
    }
}