#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,qv;
  cin>>n>>qv;
  vector<int>p(n);
  for(int i=1;i<n;i++)cin>>p[i],p[i]--;
  vector<int>base(n);
  for(auto &x:base)cin>>x,x--;
  vector<vector<int>>adj(n);
  for(int i=1;i<n;i++)adj[p[i]].push_back(i);
  multiset<int>st[n];
  for(int i=1;i<n;i++)st[p[i]].insert(0);
  priority_queue<pair<int,int>>q;
  q.push({0,0});
  int sz=0;
  vector<int>rs(n);
  vector<int>val(n);
  while(q.size())
  {
      int idx=q.top().second;
      q.pop();
      int ans=0;
      int v=idx;
      int cur_v=0;
      int ol_dep=0;
      while(v)
      {
          int old_v=v;
          v=p[v];
          val[old_v]=max(val[old_v],++cur_v);
          for(auto &x:adj[v])if(x!=old_v)ans=max(ans,val[x]);
      }
     // cout<<idx<<" "<<ans<<endl;
      rs[idx]=sz-ans;
      for(auto &y:adj[idx])q.push({base[y],y});
      sz++;
     // cout<<idx<<" "<<sz<<" "<<ans<<" "<<rs[idx]<<endl;
  }
  while(qv--)
  {
      int x;
      cin>>x;
      x--;
      cout<<rs[x]<<" ";
  }
  cout<<endl;
}
