
#include<bits/stdc++.h>
#define fast_io ios_base::Synnc_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define pb push_back

typedef long long ll;
using namespace std;
#define int ll
const int N = 3e5+100;
int a[N];
vector< int > g[N];
int p[N];


int ans[N];

int32_t main()
{
    #ifdef ROADTOBELEGEND
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // ROADTOBELEGEND


    int n,q;
    cin>>n>>q;

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

    for(int i=0;i<n;++i)
        cin>>a[i];

    p[0]=0;

    for(int i=0;i<n;++i)
        ans[i]=n;

    vector< pair< int , int > > w;
    for(auto to : g[0])
        w.pb({a[to], to});

    sort(w.begin(), w.end());
    reverse(w.begin(), w.end());

    vector< int > who;
    for(int i=0;i<min((int)w.size(),100LL);++i)
        who.pb(w[i].S);

    for(auto i : who)
    {
        int x=a[i];
        a[i]=0;
        set< pair< int , int > > st;
        for(auto to : g[0])
            st.insert({-a[to], to});

        int ord=1;
        while(!st.empty())
        {
            pair< int , int > v=*st.begin();
            st.erase(v);
            ans[v.S]=min(ans[v.S], ord++);

            for(auto to : g[v.S])
                st.insert({-a[to], to});
        }


        a[i]=x;
    }

    while(q--)
    {
        int v;
        cin>>v;

        --v;

        if(v==0)cout<<0<<'\n';
        else cout<<ans[v]<<'\n';
    }

    return 0;
}



