#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
char st[200000 + 5];
int f[200000 + 5], F[200000 + 5], g[200000 + 5], from[200000 + 5],
    dep[200000 + 5], n, head[200000 + 5];
int cnt = 0, mx[200000 + 5], h[200000 + 5], H[200000 + 5], d[200000 + 5],
    mn[200000 + 5];
struct edge {
  int to, next;
} e[200000 * 2 + 5];
inline void ins(int f, int t) {
  e[++cnt] = (edge){t, head[f]};
  head[f] = cnt;
  e[++cnt] = (edge){f, head[t]};
  head[t] = cnt;
}
void Pre(int x, int fa) {
  f[x] = F[x] = dep[x];
  h[x] = int(1e9);
  for (int i = head[x]; i; i = e[i].next)
    if (e[i].to != fa) {
      dep[e[i].to] = dep[x] + 1;
      Pre(e[i].to, x);
      if (f[e[i].to] > f[x])
        F[x] = f[x], f[x] = f[e[i].to], from[x] = e[i].to;
      else
        F[x] = max(F[x], f[e[i].to]);
      H[x] += H[e[i].to];
      if (H[e[i].to]) h[x] = min(h[x], f[e[i].to]);
    }
  if (st[x] == '1') h[x] = min(h[x], f[x]), H[x] += 1;
}
void Dfs(int x, int fa) {
  if (st[x] == '0') mn[x] = min(h[x] - dep[x], d[x]);
  mx[x] = min(max(f[x] - dep[x], g[x]) - 1, f[x] - dep[x] + 1);
  for (int i = head[x]; i; i = e[i].next)
    if (e[i].to != fa) {
      int dis2 = max((e[i].to == from[x] ? F[x] : f[x]) - dep[x], g[x]);
      mx[x] = min(mx[x], dis2 + 1);
      g[e[i].to] = dis2 + 1;
      d[e[i].to] = min(d[x] + 1, g[x] - g[e[i].to] > 0 ? dis2 + 1 : int(1e9));
      Dfs(e[i].to, x);
    }
}
long long ans = 1;
int main() {
  n = read();
  for (int i = 1; i < n; ++i) ins(read(), read());
  scanf("%s", st + 1);
  Pre(1, 0);
  d[1] = int(1e9);
  Dfs(1, 0);
  for (int i = 1; i <= n; ++i) ans += max(0, mx[i] - mn[i] + 1);
  printf("%lld\n", ans);
  return 0;
}
