#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
struct node {
    int to,next;
}E[MAXN * 2];
int N,head[MAXN],sumE,dep[MAXN],fr[MAXN],high[MAXN],low[MAXN];
char s[MAXN];
vector<int> rec[MAXN];
vector<pii > to[MAXN];
void add(int u,int v) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    head[u] = sumE;
}
void dfs1(int u,int fa) {
    for(int i = head[u] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(v != fa) {
	    dfs1(v,u);
	    dep[u] = max(dep[u],dep[v] + 1);
	}
    }
}
void dfs2(int u,int fa) {
    vector<pii > vec;
    dep[u] = max(dep[u],fr[u] + 1);
    vec.pb(mp(1,u));
    if(fa) vec.pb(mp(fr[u] + 2,fa));
    pii p = mp(0,0);
    for(int i = head[u] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(v != fa) {
	    vec.pb(mp(dep[v] + 2,v));
	    if(dep[v] > dep[p.se]) p.se = v;
	    if(dep[p.se] > dep[p.fi]) swap(p.fi,p.se);
	}
    }
    sort(vec.begin(),vec.end());
    high[u] = dep[u] - 1;
    int s = vec.size() - 1;
    high[u] = min(high[u],vec[s - 1].fi);
    if(high[u] < dep[u] - 1){
	to[u].pb(mp(vec[s].se,high[u]));
    }
    vec.clear();
    for(int i = head[u] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(v != fa) {
	    fr[v] = max(fr[v],fr[u] + 1);
	    if(v != p.fi) fr[v] = max(fr[v],dep[p.fi] + 1);
	    if(v != p.se) fr[v] = max(fr[v],dep[p.se] + 1);
	}
    }
    for(int i = head[u] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(v != fa) {
	    dfs2(v,u);
	}
    }
}
void Solve() {
    read(N);
    int a,b;
    for(int i = 1 ; i < N ; ++i) {
	read(a);read(b);add(a,b);add(b,a);
    }
    scanf("%s",s + 1);
    dep[0] = -1;fr[1] = -1;
    dfs1(1,0);dfs2(1,0);
    for(int i = 1 ; i <= N ; ++i) {
	rec[high[i]].pb(i);
	low[i] = high[i] + 1;
    }
    for(int i = 0 ; i <= N ; ++i) {
	for(auto v : rec[i]) {
	    if(s[v] == '1') {
		low[v] = 0;
	    }
	    if(low[v] <= high[v]){
		for(auto k : to[v]) {
		    low[k.fi] = min(low[k.fi],k.se);
		}
	    }
	}
    }
    int64 ans = 1;
    for(int i = 1 ; i <= N ; ++i) {
	ans += high[i] - low[i] + 1;
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}
