#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200010;
int n,L[N],siz[N];
char s[N];
vector<int> v[N];
class dat
{
	public:
		int mx1,mx2;
		void update(int v)
		{
			if(v>mx1)
			{
				mx2=mx1;
				mx1=v;
			}
			else if(v>mx2)mx2=v;
		}
}d[N],dg[N];
void dfs1(int np,int fath)
{
	L[np]=0x3f3f3f3f;
	siz[np]=(s[np]=='1');
	for(int &x:v[np])
	{
		if(x==fath)continue;
		dfs1(x,np);
		siz[np]+=siz[x];
		if(siz[x])L[np]=min(L[np],d[x].mx1+1);
		d[np].update(d[x].mx1+1);
	}
}
void dfs2(int np,int fath,int dfa)
{
	if(siz[1]-siz[np])L[np]=min(L[np],dfa+1);
	d[np].update(dfa+1);
	vector<int> ch;
	ch.push_back(0);
	for(int &x:v[np])
	{
		if(x==fath)continue;
		ch.push_back(x);
	}
	ch.push_back(0);
	vector<int> pre(ch.size()),suf(ch.size());
	for(int i=1;i+1<pre.size();i++)pre[i]=max(pre[i-1],d[ch[i]].mx1+1);
	for(int i=suf.size()-2;i>=1;i--)suf[i]=max(suf[i+1],d[ch[i]].mx1+1);
	for(int i=1;i+1<ch.size();i++)
		dfs2(ch[i],np,max(dfa+1,max(pre[i-1],suf[i+1])));
}
int main()
{
	scanf("%d",&n);
	for(int i=1,ti,tj;i<n;i++)
	{
		scanf("%d%d",&ti,&tj);
		v[ti].push_back(tj);
		v[tj].push_back(ti);
	}
	scanf("%s",s+1);
	dfs1(1,0);
	dfs2(1,0,-1e9);
	ll ans=1;
	for(int i=1;i<=n;i++)
	{
		int l=(s[i]=='1'?0:L[i]),r=min(d[i].mx1,d[i].mx2+2);
		if(l<r)ans+=r-l;
	}
	printf("%lld\n",ans);
	return 0;
}