#include <bits/stdc++.h>
using namespace std;
int n, tot, cnt, tp, dfsclk, q[200009], fst[200009], pnt[200009 << 1],
    nxt[200009 << 1];
int lf[200009], rg[200009], id[200009], anc[200009], sz[200009], son[200009],
    fa[200009], d[200009], f[200009];
long long ans;
char s[200009];
struct node {
  int x, y, z;
} a[200009], b[200009], c[200009];
bool operator<(node u, node v) { return u.x < v.x; }
void add(int x, int y) {
  pnt[++tot] = y;
  nxt[tot] = fst[x];
  fst[x] = tot;
}
int find(int x, int y) {
  int t = x;
  for (; anc[x] != anc[y]; x = fa[anc[x]]) t = anc[x];
  return x == y ? t : id[lf[y] + 1];
}
void calc(int x) {
  int i, y;
  if (b[x].x)
    c[cnt = 1] = b[x];
  else
    cnt = 0;
  for (i = fst[x]; i; i = nxt[i]) {
    y = pnt[i];
    if (y != fa[x]) c[++cnt] = a[y];
  }
  sort(c + 1, c + cnt + 1);
  int l = 0, r = c[cnt].x - 1;
  if (b[x].x == c[cnt].x)
    r = min(r, a[x].x);
  else {
    for (i = fst[x]; i; i = nxt[i]) {
      y = pnt[i];
      if (y != fa[x] && c[cnt].x == a[y].x) {
        r = min(r, b[y].x);
        break;
      }
    }
  }
  if (s[x] == '0') {
    l = 1000000000;
    for (i = 1; i <= cnt; i++) {
      y = c[i].y;
      if (!y) continue;
      if (c[i].x < c[cnt].x) l = min(l, c[cnt - 1].x);
      if (lf[y] <= lf[x] && lf[x] <= rg[y]) {
        y = find(x, y);
        l = min(l, c[i].z + a[y].x);
      } else {
        l = min(l, c[i].z + b[y].x);
      }
    }
    if (cnt > 1) l = max(l, c[cnt - 1].x);
  }
  ans += max(0, r - l + 1);
}
void dfs(int x) {
  int i, y;
  sz[x] = 1;
  for (i = fst[x]; i; i = nxt[i]) {
    y = pnt[i];
    if (y != fa[x]) {
      fa[y] = x;
      d[y] = d[x] + 1;
      dfs(y);
      sz[x] += sz[y];
      if (sz[y] > sz[son[x]]) son[x] = y;
      a[x] = max(a[x], a[y]);
    }
  }
  a[x].x++;
  if (s[x] == '1') {
    a[x].y = x;
    a[x].z = 1;
  }
}
void dvd(int x, int tp) {
  int i, y;
  lf[x] = ++dfsclk;
  id[dfsclk] = x;
  anc[x] = tp;
  if (son[x]) dvd(son[x], tp);
  for (i = fst[x]; i; i = nxt[i]) {
    y = pnt[i];
    if (y != fa[x] && y != son[x]) dvd(y, y);
  }
  rg[x] = dfsclk;
}
void dfs2(int x) {
  int i, y;
  for (i = fst[x], tp = 0; i; i = nxt[i]) {
    y = pnt[i];
    if (y != fa[x]) q[++tp] = y;
  }
  node tmp = b[x];
  for (i = 1; i <= tp; i++) {
    y = q[i];
    b[y] = max(b[y], tmp);
    tmp = max(tmp, (node){a[y].x, a[y].y, a[y].z});
  }
  for (i = tp, tmp.x = -1000000000; i; i--) {
    y = q[i];
    b[y] = max(b[y], tmp);
    tmp = max(tmp, (node){a[y].x, a[y].y, a[y].z});
  }
  for (i = 1; i <= tp; i++) {
    b[q[i]].x++;
    b[q[i]].z++;
  }
  if (s[x] == '1')
    for (i = 1; i <= tp; i++) {
      b[q[i]].y = x;
      b[q[i]].z = 1;
    }
  for (i = fst[x]; i; i = nxt[i]) {
    y = pnt[i];
    if (y != fa[x]) dfs2(y);
  }
}
int main() {
  scanf("%d", &n);
  int i, x, y;
  for (i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  scanf("%s", s + 1);
  dfs(1);
  dvd(1, 1);
  if (s[1] == '0') b[1].z = 1000000000;
  dfs2(1);
  for (i = 1; i <= n; i++) calc(i);
  printf("%lld\n", ans + 1);
  return 0;
}
