#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define MXN 200005
vector<pii> v[200005];
int dep[200005];
void dfs(int x,int f){
    for(auto &it:v[x]){
        if(it.y!=f){
            dfs(it.y,x);
            it.x=dep[it.y]+1;
           // printf("%d %d %d\n",x,it.y,it.x);
        }
    }
    sort(v[x].begin(),v[x].end());
    reverse(v[x].begin(),v[x].end());
    if(f!=0&&v[x].size()==1);
    else
    dep[x]=v[x][0].x;
}
void dfs2(int x,int f,int sum){
    for(auto it:v[x]){
        if(it.y!=f){
            if(it.x==v[x][0].x){
                if(v[x].size()==1){
                    dfs2(it.y,x,sum+1);
                }
                else{
                    dfs2(it.y,x,max(v[x][1].x,sum)+1);
                }
            }
            else{
                dfs2(it.y,x,max(v[x][0].x,sum)+1);
            }
        }
    }
    if(f!=0){
        v[x].back().x=sum;
    }
}
int val[200005];
int l[200005];
int d[200005];
int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1;i<n;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        v[x].pb(mp(-1,y));
        v[y].pb(mp(-1,x));
        d[x]++;
        d[y]++;
    }
    dfs(1,0);
    dfs2(1,0,0);
    LL ans=0;
    for(int i = 1;i<=n;i++){
        sort(v[i].begin(),v[i].end());
        reverse(v[i].begin(),v[i].end());
      //  for(auto it:v[i])
      //  printf("%d ",it.x);
      //  printf("\n");
        if(v[i].size()==1){
       //     ans+=2;
            val[i]=2;
            v[i].pb(mp(0,0));
            if(v[i][0].x==1)val[i]--;
            
        }
        else{
         //   ans+=v[i][1].x+2;
            val[i]=v[i][1].x+2;
            if(v[i][1].x==v[i][0].x)val[i]-=2;
            if(v[i][1].x==v[i][0].x-1)val[i]--;
        }
     //   printf("%d %lld\n",i,ans);
    }
    char c[200005];
    scanf("%s",c+1);
    queue<int> q;
    for(int i = 1;i<=n;i++){
        if(c[i]=='1'){
            q.push(i);
            l[i]=0;
        }
        else{
            l[i]=1e9;
        }
        d[i]--;
        val[i]--;
        if(d[i]==0)q.push(i);

    }
    while(!q.empty()){
        int x=q.front();
        q.pop();
        if(v[v[x][0].y][0].y==x){
 
        }
        else{
            if(--d[v[x][0].y]==0){
                q.push(v[x][0].y);
            }
        }
       /* if(c[x]=='1'){
            l[v[x][0].y]=min(l[v[x][0].y],v[x][1].x+1);
        }
        else{*/
            if(val[x]>=l[x])
            l[v[x][0].y]=min(l[v[x][0].y],v[x][1].x+1);
        //}
    }
    for(int i = 1;i<=n;i++){
        //printf("%d %d %d\n",val[i],l[i],ans);
        if(val[i]>=l[i])
        {   
           // printf("%d %d %d\n",i,val[i],l[i]);
            ans+=val[i]-l[i]+1;
        }
    }
    printf("%lld\n",ans+1);
}