#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int n = 0, f = 1;
  char c;
  for (c = getchar(); (c < '0' || c > '9') && c != '-'; c = getchar())
    ;
  if (c == '-') c = getchar(), f = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - 48;
  return n * f;
}
const int maxn = 2e5 + 5;
int i, j, n, k[maxn], ne[maxn << 1], g[maxn << 1], num;
int d[maxn], mx[maxn], fa[maxn], cnt, son[maxn];
int p[maxn], high[maxn], low[maxn];
char s[maxn];
long long ans;
void add(int x, int y) { ne[++num] = k[x], k[x] = num, g[num] = y; }
void dfs(int x) {
  int i, f = fa[x];
  for (i = k[x]; i; i = ne[i]) {
    int go = g[i];
    if (go != f) {
      fa[go] = x, dfs(go);
      mx[x] = (mx[x] > mx[go] + 1 ? mx[x] : mx[go] + 1);
    }
  }
}
void df(int x, int y) {
  d[x] = (mx[x] > y ? mx[x] : y);
  int i, f = fa[x], now = y + 1;
  cnt = 0;
  for (i = k[x]; i; i = ne[i]) {
    int go = g[i];
    if (go != f) {
      p[go] = (p[go] > now ? p[go] : now), son[++cnt] = go;
      now = (now > mx[go] + 2 ? now : mx[go] + 2);
    }
  }
  now = y + 1;
  for (i = cnt; i >= 1; i--) {
    int go = son[i];
    p[go] = (p[go] > now ? p[go] : now);
    now = (now > mx[go] + 2 ? now : mx[go] + 2);
  }
  for (i = k[x]; i; i = ne[i]) {
    int go = g[i];
    if (go != f) df(go, p[go]);
  }
}
void work(int x) {
  int i, f = fa[x];
  high[x] = (mx[x] + 1 < d[x] - 1 ? mx[x] + 1 : d[x] - 1);
  if (s[x] == '1')
    low[x] = 0;
  else
    low[x] = n;
  for (i = k[x]; i; i = ne[i]) {
    int go = g[i];
    if (go != f) {
      work(go);
      low[x] = (high[go] < low[x] ? high[go] : low[x]);
    }
  }
  ans += (0 > high[x] - low[x] + 1 ? 0 : high[x] - low[x] + 1);
}
int main() {
  n = read();
  for (i = 1; i <= n - 1; i++) {
    int x = read(), y = read();
    add(x, y), add(y, x);
  }
  scanf("%s", s + 1);
  dfs(1);
  df(1, 0);
  work(1);
  printf("%lld\n", ans + 1);
}
