#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, mx[N], se[N], low[N], z[N];
vector<int> e[N];
char s[N];
long long ans;
inline void upd(int x, int u) {
  if (u > mx[x])
    se[x] = mx[x], mx[x] = u;
  else if (u > se[x])
    se[x] = u;
}
void dfs1(int x, int fa) {
  low[x] = N;
  if (s[x] == '1') low[x] = 0, z[x] = 1;
  for (int v : e[x])
    if (v != fa) {
      dfs1(v, x);
      int d = mx[v] + 1;
      upd(x, d);
      if (z[v]) low[x] = min(low[x], d), z[x] += z[v];
    }
}
void dfs2(int x, int fa) {
  if (fa) {
    int d = mx[x] + 1 == mx[fa] ? se[fa] + 1 : mx[fa] + 1;
    upd(x, d);
    if (z[fa] > z[x]) low[x] = min(low[x], d);
  }
  for (int v : e[x])
    if (v != fa) dfs2(v, x);
  int l = low[x], r = min(se[x] + 1, mx[x] - 1);
  if (l <= r) ans += r - l + 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1, u, v; i < n; i++)
    scanf("%d%d", &u, &v), e[u].push_back(v), e[v].push_back(u);
  scanf("%s", s + 1);
  dfs1(1, 0);
  dfs2(1, 0);
  printf("%lld\n", ans + 1);
  return 0;
}
