#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=200005;
int f[N],from[N],d[N],q[N],n,a,b,rt,rt2;
char s[N];
vi e[N];
ll ans;

void diameter(){
	int r=0,u;
	fill(d,d+n+1,-1);
	d[1]=0,q[r++]=1;
	for(int l=0;l<r;l++){
		u=q[l];
		REP(k,SZ(e[u])){
			if(d[e[u][k]]==-1){
				d[e[u][k]]=d[u]+1;
				q[r++]=e[u][k];
			}
		}
	}
	fill(d,d+n+1,-1),r=0;
	d[u]=0,q[r++]=u;
	for(int l=0;l<r;l++){
		u=q[l];
		REP(k,SZ(e[u])){
			if(d[e[u][k]]==-1){
				d[e[u][k]]=d[u]+1;
				from[e[u][k]]=u;
				q[r++]=e[u][k];
			}
		}
	}
	vi pt;
	for(;u;u=from[u]){
		pt.pb(u);
//		cout<<"@"<<u<<endl;
	}
	if(SZ(pt)&1){
		rt=pt[SZ(pt)/2];
	}
	else{
		rt=pt[SZ(pt)/2-1];
		rt2=pt[SZ(pt)/2];
	}
}

void dfs(int u,int fa){
	d[u]=0,f[u]=N;
	REP(k,SZ(e[u])){
		int v=e[u][k];
		if(v==fa) continue;
		dfs(v,u);
		d[u]=max(d[u],d[v]+1);
		ans+=max(0,d[v]+2-f[v]);
//		cout<<"#"<<v<<" "<<max(0,d[v]+2-f[v])<<endl;
		f[u]=min(f[u],max(f[v],d[v]+1));
	} 
	if(s[u]=='1'){
		f[u]=0;
	}
//	cout<<"!"<<u<<" "<<fa<<"  "<<d[u]<<" "<<f[u]<<endl;
}

int main(){
	read(n);
	rep(i,1,n-1){
		read(a),read(b);
		e[a].pb(b),e[b].pb(a);
	}
	scanf("%s",s+1);
	diameter();
	if(!rt2){
		dfs(rt,0);
		ans+=max(0,d[rt]-f[rt]);
	}
	else{
		dfs(rt,rt2);
		ans+=max(0,d[rt]-f[rt]+1);
		dfs(rt2,rt);
		ans+=max(0,d[rt2]-f[rt2]+1);
	}
	cout<<ans+1<<endl;
	return 0;
}