#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005, inf = 0x3f3f3f3f;
inline int read() {
  int ret, f = 1;
  char c;
  while ((c = getchar()) && (c < '0' || c > '9'))
    if (c == '-') f = -1;
  ret = c - '0';
  while ((c = getchar()) && (c >= '0' && c <= '9'))
    ret = (ret << 3) + (ret << 1) + c - '0';
  return ret * f;
}
int n;
char s[maxn];
long long ans;
int head[maxn], tot;
struct edge {
  int nxt, to;
} e[maxn];
void Addedge(int x, int y) {
  e[++tot] = (edge){head[x], y};
  head[x] = tot;
}
int f[maxn][2], siz[maxn], bat[maxn];
void dfs1(int x, int fa) {
  siz[x] = (s[x] == '1');
  bat[x] = (s[x] == '1' ? 0 : inf);
  int id;
  for (int i = head[x]; i; i = e[i].nxt) {
    id = e[i].to;
    if (id == fa) continue;
    dfs1(id, x);
    if (f[id][0] + 1 > f[x][0]) {
      f[x][1] = f[x][0];
      f[x][0] = f[id][0] + 1;
    } else if (f[id][0] + 1 > f[x][1]) {
      f[x][1] = f[id][0] + 1;
    }
    siz[x] += siz[id];
    if (siz[id]) bat[x] = min(bat[x], f[id][0] + 1);
  }
}
void dfs2(int x, int fa) {
  ans += max(min(f[x][0], f[x][1] + 2) - bat[x], 0);
  int id, tmp;
  for (int i = head[x]; i; i = e[i].nxt) {
    id = e[i].to;
    if (id == fa) continue;
    tmp = (f[x][0] == f[id][0] + 1 ? f[x][1] : f[x][0]) + 1;
    if (tmp + 1 > f[id][0]) {
      f[id][1] = f[id][0];
      f[id][0] = tmp;
    } else if (tmp + 1 > f[id][1])
      f[id][1] = tmp + 1;
    if (siz[id] != siz[1]) bat[id] = min(bat[id], tmp);
    dfs2(id, x);
  }
}
int main() {
  n = read();
  int u, v;
  for (int i = 1; i < n; ++i) {
    u = read();
    v = read();
    Addedge(u, v);
    Addedge(v, u);
  }
  scanf("%s", s + 1);
  dfs1(1, 0);
  dfs2(1, 0);
  printf("%lld", ans + 1);
  return 0;
}
