#include <cstdio>
#include <vector>
#define pb push_back
long long ans;
int mx[200005], sec[200005], sz[200005], mn[200005];
std::vector<int> adj[200005];
char col[200005];
void init(int u, int fa = -1)
{
	mn[u] = 1e9;
	if (col[u] == '1')
	{
		mn[u] = 0;
		sz[u] = 1;
	}
	for (int v : adj[u])
	{
		if (v == fa)
			continue;
		init(v, u);
		if (mx[v] + 1 > mx[u])
		{
			sec[u] = mx[u];
			mx[u] = mx[v] + 1;
		}
		else if (mx[v] + 1 > sec[u])
			sec[u] = mx[v] + 1;
		if (sz[v])
			mn[u] = std::min(mn[u], mx[v] + 1);
		sz[u] += sz[v];
	}
}
void calc(int u, int fa = -1)
{
	if (~fa)
	{
		int x = mx[fa] == mx[u] + 1 ? sec[fa] : mx[fa];
		if (x + 1 > mx[u])
		{
			sec[u] = mx[u];
			mx[u] = x + 1;
		}
		else if (x + 1 > sec[u])
			sec[u] = x + 1;
		if (sz[u] != sz[0])
			mn[u] = std::min(mn[u], x + 1);
	}
	for (int v : adj[u])
	{
		if (v != fa)
			calc(v, u);
	}
	ans += std::max(0, std::min(sec[u] + 1, mx[u] - 1) - mn[u] + 1);
}
int main()
{
	// freopen("AGC008-F.in", "r", stdin);
	int n;
	scanf("%d", &n);
	for (int i = 1; i < n; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		adj[--u].pb(--v);
		adj[v].pb(u);
	}
	scanf("%s", col);
	init(0);
	calc(0);
	printf("%lld\n", ans + 1);
	return 0;
}
