#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 11, inf = (1 << 30);
long long ans;
int n, tot;
int nxt[N], las[N], to[N];
int mx[N][2], sz[N], d[N];
inline void add(int x, int y) {
  nxt[++tot] = las[x], las[x] = tot, to[tot] = y;
}
inline void up(int x, int y) {
  if (y > mx[x][0])
    mx[x][1] = mx[x][0], mx[x][0] = y;
  else if (y > mx[x][1])
    mx[x][1] = y;
}
inline void dfs1(int x, int fa) {
  if (sz[x])
    d[x] = 0;
  else
    d[x] = inf;
  for (register int e = las[x]; e; e = nxt[e]) {
    int y = to[e];
    if (y == fa) continue;
    dfs1(y, x);
    up(x, mx[y][0] + 1);
    sz[x] += sz[y];
    if (sz[y]) d[x] = min(d[x], mx[y][0] + 1);
  }
}
inline void dfs2(int x, int fa) {
  int r = min(mx[x][1] + 1, mx[x][0] - 1);
  if (d[x] <= r) ans += r - d[x] + 1;
  for (register int e = las[x]; e; e = nxt[e]) {
    int y = to[e];
    if (y == fa) continue;
    int l = (mx[y][0] + 1 == mx[x][0]) ? (mx[x][1] + 1) : (mx[x][0] + 1);
    up(y, l);
    if (sz[1] - sz[y]) d[y] = min(d[y], l);
    dfs2(y, x);
  }
}
int main() {
  scanf("%d", &n);
  for (register int i = 2; i <= n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y), add(y, x);
  }
  for (register int i = 1; i <= n; ++i) scanf("%01d", sz + i);
  dfs1(1, 0), dfs2(1, 0);
  printf("%lld\n", ans + 1);
  return 0;
}
