#include <bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
const int N=2e5+50,oo=2e9;
vector<int>h[N];char s[N];
int n,c[N],fa[N],sz[N],f0[N],f1[N],g[N],gg[N];
inline void dfs1(int x,int f) {
    fa[x]=f;sz[x]=c[x];
	f0[x]=0;f1[x]=oo;
    for(auto y:h[x])
		if(y!=f){
        dfs1(y,x);sz[x]+=sz[y];
        f0[x]=max(f0[x],f0[y]+1); 
        if(f1[y]<oo)f1[x]=min(f1[x],f0[y]+1);
    }if(c[x])f1[x]=min(f1[x],f0[x]); 
}
inline void dfs2(int x,int f) {
    g[x]=max(g[x],g[f]+1);
    if(f)gg[x]=max(gg[x],g[x]-1);
    int mx;mx=-1;
    for(int y,k=0;k<(int)h[x].size();k++)
	if((y=h[x][k])!=f){
        g[y]=max(g[y],mx+2);
        mx=max(mx,f0[y]);
    }mx=-1;
    for(int y,k=h[x].size()-1;k>=0;k--)
	if((y=h[x][k])!=f){
        g[y]=max(g[y],mx+2);
        mx=max(mx,f0[y]);
    }
	for(auto y:h[x])if(y!=f)dfs2(y,x);
}
inline void addl(int x,int y){
	h[x].push_back(y);
	h[y].push_back(x);
}
int main(){
	g[0]=-1;
    memset(f1,120,sizeof(f1));
    int i;n=read();
    for(i=1;i<n;i++)addl(read(),read());
	scanf("%s",s+1);
	for(i=1;i<=n;i++)c[i]=s[i]-'0';
    dfs1(1,0);dfs2(1,0);
    long long ans=0;
    for(int i=1;i<=n;i++) {
        int up=max(f0[i],g[i])-1,dw;
		dw=c[i]?0:min(f1[i],(sz[i]==sz[1])?oo:g[i]);
        for(auto y:h[i]){
            if(y==fa[i])up=min(up,f0[i]+1);
            else up=min(up,gg[y]+1);
        }if(up>=dw)ans+=up-dw+1;
    }printf("%lld\n",ans+1);
	return 0;
}