#pragma GCC optimize(3)
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<set> 
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#define ll long long
#define db double
#define inf 200001
#define INF (int)1e9
#define mod (int)(1e9+7)
#define pi acos(-1)
#define rd(n) {n=0;char ch;int f=0;do{ch=getchar();if(ch=='-'){f=1;}}while(ch<'0'||ch>'9');while('0'<=ch&&ch<='9'){n=(n<<1)+(n<<3)+ch-48;ch=getchar();}if(f)n=-n;}
using namespace std;
int n;
 
struct edge{
    int y,nxt;
    edge(){}
    edge(int yy,int nn){
        y=yy,nxt=nn;
    }
}e[inf*2];
int head[inf],ecnt;
 
void addedge(int x,int y){
    ecnt++;
    e[ecnt]=edge(y,head[x]);
    head[x]=ecnt;
    return;
}

int p[inf],siz[inf],fa[inf],maxs[inf],maxf[inf],maxe[inf],maxex[inf];

void dfs1(int u,int last){
	fa[u]=last;
	siz[u]=p[u];
	maxs[u]=0;
	maxe[u]=INF;
	for (int i=head[u];i;i=e[i].nxt){
		int v=e[i].y;
		if (v==last){
			continue;
		}
		dfs1(v,u);
		maxs[u]=max(maxs[u],maxs[v]+1);
		siz[u]+=siz[v];
		if (maxe[v]!=INF){
			maxe[u]=min(maxe[u],maxs[v]+1);
		}
	}
	if (p[u]){
		maxe[u]=min(maxe[u],maxs[u]);
	}
	return;
}

int sta[inf],top;

void dfs2(int u){
	maxf[u]=max(maxf[u],(fa[u]!=0)+maxf[fa[u]]);
	if (fa[u]){
		maxex[u]=max(maxex[u],maxf[u]-1);
	}
	int now=-1,top=0;
	for (int i=head[u];i;i=e[i].nxt){
		int v=e[i].y;
		if (v==fa[u]){
			continue;
		}
		sta[++top]=v;
		maxf[v]=max(maxf[v],now+1);
		now=max(now,maxs[v]+1);
	}
	now=-1;
	for (int i=top;i>=1;i--){
		int v=sta[i];
		maxf[v]=max(maxf[v],now+1);
		now=max(now,maxs[v]+1);
	}
	for (int i=head[u];i;i=e[i].nxt){
		int v=e[i].y;
		if (v!=fa[u]){
			dfs2(v);
		}
	}
	return;
}

int main(){
	rd(n)
    int x,y;
    for (int i=1;i<n;i++){
        rd(x) rd(y)
        addedge(x,y);
        addedge(y,x);
    }
    for (int i=1;i<=n;i++){
        char c=getchar();
        (c!='1' && c!='0')?c=getchar():p[i]=c-'0';
    }
    dfs1(1,0);
    dfs2(1);
    ll ans=0LL;
    for (int i=1;i<=n;i++){
    	int minv,maxv;
    	if (p[i]){
    		minv=0;
		}
		else{
			minv=min(maxe[i],(siz[1]==siz[i])?INF:maxf[i]);
		}
		maxv=max(maxs[i],maxf[i])-1;
		for (int j=head[i];j;j=e[j].nxt){
			int v=e[j].y;
			if (v!=fa[i]){
				maxv=min(maxv,maxex[v]+1);
			}
		}
		if (fa[i]){
			maxv=min(maxv,maxs[i]+1);
		}
		if (maxv>=minv){
			ans+=(ll)maxv-(ll)minv+1LL;
		}
	}
	printf("%lld\n",ans+1LL);
	return 0;
}