#include<bits/stdc++.h>
using namespace std;

const int N = 2e5 + 9, INF = 0x3f3f3f3f;

int f[N], g[N], n, nf[N], ng[N], d[N];
long long ans;
bool is[N], nis[N];
char s[N];
vector<int>V[N];

void Gx (int &f, int &g, int _f) {
	if (_f >= f) g = f, f = _f;
	else if (_f >= g) g = _f;
}

void Dfs (int u, int fa) {
	if (s[u] == '1') is[u] = 1;
	for (auto v : V[u]) if (v != fa) {
		Dfs(v, u);
		is[u] |= is[v];
		if (is[v] && f[v] < d[u]) d[u] = f[v];
		Gx(f[u], g[u], f[v]);
	}
	++f[u]; ++g[u]; ++d[u];
}

void Dfs2 (int u, int fa) {
	if (nf[u] < 1) nf[u] = 1;
	Gx(f[u], g[u], nf[u]);
	nis[u] |= (s[u] == '1');
	if (nis[u] && nf[u] < d[u]) d[u] = nf[u];
	int a = nf[u], b = 0; bool o = nis[u];
	for (auto v : V[u]) if (v != fa) {
		Gx(nf[v], ng[v], a + 1);
		nis[v] |= o;
		Gx(a, b, f[v] + 1);
		if (is[v]) o |= 1;
	}
	a = b = o = 0;
	for (int i = V[u].size() - 1, v; ~i; --i) if ((v = V[u][i]) != fa) {
		Gx(nf[v], ng[v], a + 1);
		nis[v] |= o;
		
		Gx(a, b, f[v] + 1);
		if (is[v]) o |= 1;
	}
	
	for (auto v : V[u]) if (v != fa) {
		Dfs2(v, u);
	}
}

int main () {
	memset(d, 0x3f, sizeof d);
	scanf("%d", &n);
	for (int i = 1, u, v; i < n; ++i) scanf("%d%d", &u, &v), V[u].emplace_back(v), V[v].emplace_back(u);
	scanf("%s", s + 1);
	if (n == 1) return printf("%d\n", s[1] == '1'), 0;
	if (n == 2) return printf("%d\n", (s[1] == '1') + (s[2] == '1') + (s[1] == '1' || s[2] == '1')), 0;
	Dfs(1, 0);
	Dfs2(1, 0);
 	for (int i = 1; i <= n; ++i) {
 		if (s[i] == '1') d[i] = 1;
	 	ans += max(min(g[i], f[i] - 2) - (d[i] - 1) + 1, 0);
	 }
//	 for (int i = 1; i <= n; ++i) printf("%d%c", f[i], i==n?'\n':' ');
//	 for (int i = 1; i <= n; ++i) printf("%d%c", g[i], i==n?'\n':' ');
//	 for (int i = 1; i <= n; ++i) printf("%d%c", d[i], i==n?'\n':' ');
	printf("%lld\n", ans + 1);
	return 0;
}