#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 200003;

int f[N],g[N],w[N],sec[N];
int dfn[N],k,R[N];
bool bz[N],key[N],pre[N],suf[N],s[N];
int n;
struct edge{
	int x,nxt;
}e[N*2];
int h[N],tot;
int fa[N];

void inse(int x,int y){e[++tot].x=y;e[tot].nxt=h[x];h[x]=tot;}

void dfs1(int x){
	bz[x]=1;
	dfn[x]=++k;
	pre[k]=suf[k]=s[x]=key[x];
	for(int p=h[x];p;p=e[p].nxt)
	if (!bz[e[p].x]){
		fa[e[p].x]=x;
		dfs1(e[p].x);
		s[x]|=s[e[p].x];
		if (f[e[p].x]>f[x]){
			sec[x]=f[x];
			f[x]=f[e[p].x];
			w[x]=e[p].x;
		}
		else sec[x]=max(sec[x],f[e[p].x]);
	}
	f[x]++;
	sec[x]++;
	R[x]=k;
}

void dfs2(int x){
	for(int p=h[x];p;p=e[p].nxt)
	if (fa[e[p].x]==x){
		if (e[p].x==w[x])g[e[p].x]=max(sec[x],g[x])+1;
		else g[e[p].x]=max(f[x],g[x])+1;
		dfs2(e[p].x);
	}
}

int t,a[N];

int calc(int x){
	a[t=1]=g[x]-1;
	for(int p=h[x];p;p=e[p].nxt)if (fa[e[p].x]==x)a[++t]=f[e[p].x];
	sort(a+1,a+1+t);
	int high=a[t]-1;
	if (t>1)high=min(high,a[t-1]+1);
	else high=min(high,1);
	int low=key[x]?0:1e+9;
	for(int p=h[x];p;p=e[p].nxt)if (s[e[p].x])low=min(low,f[e[p].x]);
	if (pre[dfn[x]-1]||suf[R[x]+1])low=min(low,g[x]-1);
	return max(high-low+1,0);
}

int main(){
	n=get();
	fo(i,2,n){
		int x=get(),y=get();
		inse(x,y),inse(y,x);
	}
	char str[N];
	scanf("%s",str+1);
	fo(i,1,n)key[i]=str[i]-'0';
	dfs1(1);
	dfs2(g[1]=1);
	fo(i,1,n)pre[i]|=pre[i-1];
	fd(i,n,1)suf[i]|=suf[i+1];
	LL ans=1;
	fo(i,1,n)ans+=calc(i);
	printf("%lld\n",ans);
	return 0;
}