#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);
  vector<pair<int,int>>max_v(n);
  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];
          if(max_v[v].first!=val[old_v])ans=max(ans,max_v[v].first);
          else ans=max(ans,max_v[v].second);
          if(max_v[v].first==val[old_v])
          {
              max_v[v].first++;
          }
          else if(max_v[v].second==val[old_v])
          {
              max_v[v].second++;
          }
          else
          {
              max_v[v].second=max(max_v[v].second,val[old_v]+1);
          }
          if(max_v[v].first<max_v[v].second)swap(max_v[v].first,max_v[v].second);
          val[old_v]++;
      }
      rs[idx]=sz-ans;
      for(auto &y:adj[idx])q.push({base[y],y});
      sz++;
  }
  while(qv--)
  {
      int x;
      cin>>x;
      x--;
      cout<<rs[x]<<" ";
  }
  cout<<endl;
}
