#include <cstdio>
#include <vector>
#include <assert.h>
inline void cmax(int &x, int y)
{
	if (y > x)
		x = y;
}
inline void cmax(int &x, int &y, int z)
{
	if (z > x)
		y = x, x = z;
	else if (z > y)
		y = z;
}
inline int abs(int x)
{
	return x < 0 ? -x : x;
}
typedef int ixn[200001];
typedef int ixe[399999];
int N, E, G;
ixn head, f0, f1, g, q, fa, f, w;
ixe next, to;
char s[200002];
long long O = 1;
std::vector < int > V[200001];
std::vector < std::pair < int, int > > C[200001];
void BFS()
{
	int H = 0, T = 1, u;
	q[1] = 1;
	while (H < T)
		for (int e = head[u = q[++H]]; e; e = next[e])
			if (to[e] != fa[u])
				fa[q[++T] = to[e]] = u;
	for (int i = N; i; i--)
	{
		int u = q[i];
		for (int e = head[u]; e; e = next[e])
			if (to[e] != fa[u])
				cmax(f0[u], f1[u], f0[to[e]] + 1);
	}
	for (int i = 1; i <= N; i++)
	{
		int u = q[i], first = f0[u], second = f1[u];
		if (i > 1)
			cmax(first, second, g[u] + 1);
		for (int e = head[u]; e; e = next[e])
			if (to[e] != fa[u])
				g[to[e]] = f0[to[e]] + 1 == first ? second : first;
	}
}
int F(int x)
{
	return f[x] == x ? x : f[x] = F(f[x]);
}
inline void activate(int u)
{
	// printf("activate(%d)\n", u);
	w[u] = 1;
	G++;
}
inline void connect(int u, int v)
{
	// printf("connect(%d, %d)\n", u, v);
	u = F(u), v = F(v);
	if (u != v)
	{
		G -= w[u] + w[v];
		f[v] = u;
		w[u] |= w[v];
		G += w[u];
	}
}
int main()
{
	scanf("%d", &N);
	for (int i = 1, u, v; i < N; i++)
	{
		scanf("%d%d", &u, &v);
		next[++E] = head[u], to[E] = v, head[u] = E;
		next[++E] = head[v], to[E] = u, head[v] = E;
	}
	scanf("%s", s + 1);
	BFS();
	for (int i = 2; i <= N; i++)
		C[std::max(abs(f0[i] - g[i]) - 1, 0)].push_back({ i, fa[i] });
	for (int i = 1; i <= N; i++)
		if (s[i] == '1')
			V[std::max(f0[i], i == 1 ? 0 : g[i] + 1)].push_back(i);
	for (int i = 1; i <= N; i++)
		f[i] = i;
	for (int i = N; i; i--)
	{
		for (int u : V[i])
			activate(u);
		for (auto e : C[i])
			connect(e.first, e.second);
		O += G;
		// printf("i=%d G=%d\n", i, G);
	}
	printf("%lld\n", O);
	return 0;
}
