#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define fore(e, u, v) for (int p = e(u), v = e[p].y; p; v = e[p = e[p].nxt].y)
#define ri rd<int>
using namespace std;
typedef long long LL;
const int maxN = 2e5 + 7;
const int INF = 1e9 + 7;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n;
int depth[maxN];
int sz[maxN], tot;
LL ans;

char s[maxN];
struct Vec {
	static const int maxE = maxN;
	int g[maxN], te; 
	struct edge {int y, nxt;} e[maxE << 1];
	inline void push(int x, int y) { e[++te] = (edge){y, g[x]}; g[x] = te; }
	inline void link(int x, int y) { push(x, y), push(y, x); }
	inline int& operator () (int x) { return g[x]; }
	inline edge& operator [] (int x) { return e[x]; }
}e;

void dfs1(int x, int fa) {
	depth[x] = 1;
	sz[x] = s[x] == '1';
	fore (e, x, y) if (y != fa) {
		dfs1(y, x);
		depth[x] = max(depth[x], depth[y] + 1);
		sz[x] += sz[y];
	}
}

void dfs2(int x, int fa) {
	int mx = 0, sec = 0, id = 0, least = s[x] == '1' ? 0 : INF;
	fore (e, x, y) {
		if (depth[y] > mx) sec = mx, mx = depth[y], id = y;
		else if (depth[y] > sec) sec = depth[y];
		if (s[x] == '0' && sz[y]) least = min(least, depth[y]);
	}
	ans += max(0, min(mx-1, sec+1) - least + 1);
	fore (e, x, y) if (y != fa) {
		sz[x] = tot - sz[y];
		if (y != id) depth[x] = mx+1, dfs2(y, x);
		else depth[x] = sec+1, dfs2(y, x);
	}
}

int main() {
	n = ri();
	For (i, 1, n) e.link(ri(), ri());
	scanf("%s", s+1);
	rep (i, 1, n) if (s[i] == '1') ++ tot;

	dfs1(1, 0);
	dfs2(1, 0);

	printf("%lld\n", ans+1);

	return 0;
}
