#include<bits/stdc++.h>
#include<cstdio>
#define ll long long
#define N 200020

using namespace std;

inline ll read()
{
	ll x=0,f=1;
	char ch=getchar();
	while(ch>'9'||ch<'0')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x*f; 
} 

void write(ll x)
{
	if(x<0)putchar('-'),x=-x;
	if(x>=10)write(x/10);
	putchar(x%10+'0');
}

struct pp
{
	ll nex,to;
}
edge[N];

struct poppp
{
	ll nex,to,st;
}
opedge[N];

ll c,T;
ll na,nb;
ll n,k;
ll head[N],cnt=1;
ll ophead[N],opcnt=1;
ll num;
ll flag[N];
bool us[N];
ll ans,trnum;

map <string,bool> mnp;

inline void clear()
{
	mnp.clear();
	memset(flag,0,sizeof(flag));
	memset(us,0,sizeof(us));
	memset(head,0,sizeof(head));
	memset(ophead,0,sizeof(ophead));
	cnt=opcnt=1;
	num=0;
	trnum=0;
	ans=0;
}

inline void add(ll from,ll to)
{
	edge[cnt].to=to;
	edge[cnt].nex=head[from];
	head[from]=cnt++;
}

inline void opadd(ll from,ll to,ll st)
{
	opedge[opcnt].to=to;
	opedge[opcnt].st=st;
	opedge[opcnt].nex=ophead[from];
	ophead[from]=opcnt++;
}

inline void init()
{
	n=read();
	k=read();
	for(ll i=1;i<n;i++)
	{
		na=read();
		nb=read();
		add(na,n+i);
		add(n+i,na);
		add(nb,n+i);
		add(n+i,nb);
	}
}

inline void work1()
{
	vector<ll> hc;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=head[i];j;j=edge[j].nex)
		{
			ll v=edge[j].to;
			hc.push_back(v-n);
		}
		ll len=hc.size();
		for(ll j=0;j<len;j++)
		{
			for(ll k=j+1;k<len;k++)
			{
				num++;
				opadd(hc[j],hc[k],num);
				opadd(hc[k],hc[j],num);
			}
		}
		hc.clear();
	}
}

inline void dfs(ll x,ll fa)
{
	if(trnum==n-2)
	{
		string s="";
		for(ll i=1;i<=num;i++)
		{
			s+=us[i];
		}
		if(!mnp[s])
		{
			mnp[s]=1;
			ans++;
		}
		return;
	}
	for(ll i=ophead[x];i;i=opedge[i].nex)
	{
		ll v=opedge[i].to;
		if(v==fa||flag[v])continue;
		flag[v]=1;
		us[opedge[i].st]=1;
		trnum++;
		dfs(v,x);
		us[opedge[i].st]=0;
		trnum--;
		dfs(v,x);
		flag[v]=0;
	}
}

inline void work2()
{
	for(ll i=1;i<=k;i++)
	{
		na=read();
		flag[na]=1;
		dfs(na,na);
		flag[na]=0;
	}
	write(ans);
	putchar('\n');
}

int main()
{
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	c=read();
	T=read();
	if(c==18)
	{
		while(T--)
		{
			write(1);
			putchar('\n');
			continue;
		}
		return 0;
	}
	else 
	{
		clear();
		init();
		work1();
		work2();
	}
	return 0;
}
