    #include <bits/stdc++.h>
    #define pb push_back
    #define cmin(a,b) (a>b?a=b:a)
    #define cmax(a,b) (a<b?a=b:a)
    #define mem(a,k) memset(a,k,sizeof(a))
    #define lop(i,s,t) for(int i=s;i<(t);++i)
    #define rep(i,s,t) for(int i=s;i<=(t);++i)
    #define dec(i,s,t) for(int i=s;i>=(t);--i)
    #define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
    using namespace std;
     
    #define Pr(f,...) fprintf(stdout,f,##__VA_ARGS__),fflush(stdout)
     
    typedef long long ll;
     
    template<typename T>
    void read(T &x){
    	x=0; 
    	char c;
    	for(c=getchar();!isdigit(c);c=getchar()); 
    	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
    }
     
    const int N=2e5+50,oo=N;
     
    char col[N]; 
    int siz[N],n,mx[N],sc[N],R[N],L[N]; 
    ll ans;
    vector<int> g[N]; 
     
    void chkMx(int v,int w){
    	if(w>mx[v]){
    		sc[v]=mx[v];
    		mx[v]=w;
    	}else if(w>sc[v]){
    		sc[v]=w;
    	}
    }
     
    void dp(int v,int p){
    	mx[v]=0;
    	sc[v]=-oo;
    	L[v]=oo;
    	siz[v]=col[v]-'0';
    	for(int d:g[v])if(d!=p){
    		dp(d,v);
    		chkMx(v,mx[d]+1); 
    		siz[v]+=siz[d];
    		if(siz[d])cmin(L[v],mx[d]+1); 
    	}
    }
     
    void calc(int v,int p,int uMx){
    	chkMx(v,uMx); 
    	R[v]=min(mx[v],sc[v]+2)-1;
    	if(col[v]=='1')L[v]=0;
    	for(int d:g[v])if(d!=p){
    		int u=mx[v]==mx[d]+1?sc[v]+1:mx[v]+1;
    		if(siz[1]-siz[d]>0)cmin(L[d],u); 
    		calc(d,v,u); 
    	}
    }	
     
    int main(int argc,char *argv[]){
    #ifdef CURIOUSCAT
    	//freopen("dat.in","r",stdin);
    	//freopen("my.out","w",stdout);
    #endif
    	read(n); 
    	rep(i,1,n-1){
    		int u,v; 
    		read(u),read(v); 
    		g[u].pb(v); 
    		g[v].pb(u); 
    	}	
    	scanf("%s",col+1); 
    	dp(1,0); 
    	calc(1,0,0); 
    	rep(i,1,n){
    		ans+=max(0,R[i]-L[i]+1);
    		//Pr("v=%d,L[v]=%d,R[v]=%d\n",i,L[i],R[i]); 
    	}
    	printf("%lld\n", ans+1);
    	return 0;
    }
     