#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long
using oset = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 3e5, inf = 1e9;

vector<vector<int>> g(N + 1);
int s[N + 1], gl[N + 1];
int ans[N + 1], mn[N + 1];


int32_t main()
{
    int n, q;
    cin >> n >> q;
    int p[n + 1];
    for(int i = 2;i <= n;i++){
        cin >> p[i];
        g[p[i]].push_back(i);
    }
    for(int i = 1;i <= n;i++){
        cin >> s[i];
    }
    for(int i = 1, x;i <= q;i++){
        cin >> x;
        if(x == 1) continue;
        int v = x, mx = inf, dl = 0, v1 = v;
        do{
            dl++;
            mx = min(mx, s[v]);
            v1 = v;
            v = p[v];
        }while(v != 1);
        ans[i] = ans[i] + dl;
    }
    for(int i = 1;i <= q;i++){
        cout << ans[i] - mn[i] << " ";
    }

    return 0;
}
