#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 200005;

int n, m, f[MAXN], siz[MAXN];
vector <int> adj[MAXN];
bool a[MAXN];
char s[MAXN];
LL ans = 1;

inline void Dfs(int x, int p)
{
	siz[x] = a[x];
	for (auto y : adj[x])
		if (y ^ p)
			Dfs(y, x), siz[x] += siz[y], f[x] = max(f[x], f[y] + 1);
}

inline void Dfs(int x, int p, int d)
{
	vector <pii> vec;
	vec.pb(mp(0, a[x]));
	int mx1 = d, mx2 = 0, cur = 0;
	for (auto y : adj[x])
		if (y ^ p)
		{
			if (f[y] + 1 > mx2)
				mx2 = f[y] + 1;
			if (mx1 < mx2)
				swap(mx1, mx2);
			vec.pb(mp(f[y] + 1, siz[y]));
		}
	vec.pb(mp(d, m - siz[x]));
	sort(vec.begin(), vec.end());
	for (auto y : adj[x])
		if (y ^ p)
			if (f[y] + 1 == mx1)
				Dfs(y, x, mx2 + 1);
			else
				Dfs(y, x, mx1 + 1);
	for (int i = 0; i < vec.size() - 1; i ++)
		if (cur += vec[i].yy)
		{
			if (i == vec.size() - 2)
			{
				if (vec[i + 1].xx > vec[i].xx)
					ans ++;
				if (vec[i + 1].xx > vec[i].xx + 1)
					ans ++;
			}
			else
				ans += vec[i + 1].xx - vec[i].xx;
		}
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 1, x, y; i < n; i ++)
		x = Read(), y = Read(), adj[x].pb(y), adj[y].pb(x);
	scanf("%s", s + 1);
	for (int i = 1; i <= n; i ++)
		m += a[i] = s[i] - '0';
	Dfs(1, 0);
	Dfs(1, 0, 0);
	return printf("%lld\n", ans), 0;
}
