#ifndef LOCAL
#pragma GCC optimize("O3")
#endif

#include <bits/extc++.h>

using namespace std;
using namespace __gnu_pbds;
using oset = tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
const ll nMax = (1 << 19);
ll p[nMax];
vector<int> g[nMax];
ll cost[nMax];
ll s[nMax];
ll ans[nMax];
struct segtree{
    struct node{
        ll val = 0;
        node operator+(node oth){
            return node{max(val,oth.val)};
        }
    };
    vector<node> t;
    vector<int> push;
    segtree(){
        t.resize(nMax*2,node{});
        push.resize(nMax*2,0);
    }
    void add(int v, int l, int r, int ql, int qr, ll val){
        if(qr<=l || ql >=r)return;
        if(ql <= l && r <= qr){
            push[v]+=val;
            t[v].val+=val;
            return;
        }
        int m = (l+r)/2;
        add(v*2,l,m,ql,qr,val);
        add(v*2+1,m,r,ql,qr,val);
        t[v]=t[v*2]+t[v*2+1];
        t[v].val += push[v];
    }
    ll get(int v, int l, int r, int ql, int qr){
        if(qr<=l || ql >=r){
            return 0;
        }
        if(ql <=l && r <= qr){
            return t[v].val;
        }

        int m = (l+r)/2;
        return max(get(v*2,l,m,ql,qr),get(v*2+1,m,r,ql,qr)) + push[v];
    }
}st;
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin.tie(0)->sync_with_stdio(0);
    ll n, q;
    cin >> n >> q;
    //n=1e5;
    for(int i = 2; i <= n; i++){
        cin >> p[i];
       // p[i] = i/2;
        g[i].push_back(p[i]);
        g[p[i]].push_back(i);
    }
    for(int i = 1; i <=n; i++){
        cin >> s[i];
        //s[i]=i;
    }
    set<pair<int,int>>  qq;
    qq.insert({-s[1],1});
    int ord = 0;
    while(!qq.empty()){
        auto [curS,curU] = *qq.begin();
        qq.erase(qq.begin());
        for(auto v : g[curU]){
            if(v == p[curU]) continue;
            qq.insert({-s[v],v});
        }
        vector<int> ps;
        int tmp =curU;
        ps.push_back(0);
        ps.push_back(tmp);
        ps.push_back(nMax-1);
        while(tmp != 1){
            tmp = p[tmp];
            ps.push_back(tmp);
        }
        sort(ps.begin(),ps.end());
        ll bst = 0;
        for(int i = 0; i + 1 < ps.size(); i++){
            bst = max(bst, st.get(1,0,nMax,ps[i]+1,ps[i+1]));
        }
        ans[curU] = ord++ - bst;
        for(auto o : ps)st.add(1,0,nMax,o,o+1,1);
    }
for(int i = 0; i < q; i++){
    int u;
    cin >> u;
    cout << ans[u] << ' ';
}
}