#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;
int const N=3e5+10;
vector<int>nei[N];
int P[N];
int ans[N];
int qu[N];
int val[N];
int dn[N];
int sz[N];
set<pair<int,int>>s;
void dfs1(int u,int t,int x)
{
	sz[u]=1;
	if (u==x)
	{
		ans[u]=t;
		return;
	}
	s.erase({val[u],u});
	for (auto i:nei[u])
		s.insert({val[i],i});
	if (s.size())
		dfs1((*rbegin(s)).second,t+1,x);
}
void dfs2(int u)
{
	for (auto i:nei[u])
	{
		dfs2(i);
		sz[u]+=sz[i];
	}
}
void dfs(int u,int t)
{
	ans[u]=t;
	s.erase({val[u],u});
	ans[u]=t;
	if (qu[u])
	{
		int z=u;
		int f=0;
		while (P[z]!=-1)
		{
			for (auto i:nei[P[z]])
			{
				if (i==z) continue;
				f=max(f,dn[i]);
			}
			z=P[z];
		}
		for (auto i:nei[u])
			f=max(f,dn[i]);
		ans[u]-=f;
	}
	int z=u;
	while (z!=-1)
	{
		dn[z]++;
		z=P[z];
	}
	for (auto i:nei[u])
		s.insert({val[i],i});
	if (s.size())
		dfs((*rbegin(s)).second,t+1);
}
inline void solve()
{
	int n,q;
	cin>>n>>q;
	P[1]=-1;
	for (int i=2;i<=n;i++)
	{
		int x;
		cin>>x;
		P[i]=x;
		nei[x].push_back(i);
	}
	for (int i=1;i<=n;i++)
		cin>>val[i];
	vector<int>g;
	for (int i=1;i<=q;i++)
	{
		int x;
		cin>>x;
		qu[x]=i;
		g.push_back(x);
	}
	if (q<=100)
	{
		for (auto i:g)
		{
			s={};
			dfs1(1,0,i);
			dfs2(1);
			int z=i;
			int f=0;
			while (P[z]!=-1)
			{
				for (auto i:nei[P[z]])
				{
					if (i!=z) f=max(f,sz[i]);
				}
				z=P[z];
			}
			for (auto j:nei[i])
				f=max(f,sz[j]);
			ans[i]-=f;
			for (int j=1;j<=n;j++)
				sz[j]=0;
		}
	}
	else
		dfs(1,0);
	for (auto i:g)
		cout<<ans[i]<<' ';
	cout<<endl;
}
signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);cout.tie(NULL);
	int t=1;
	// cin>>t;
	while (t--)
		solve();
}