#include <bits/stdc++.h>
using namespace std;
struct node {
  int y, nex;
} a[2 * 210000];
int fir[210000], len, n, f[210000], g[210000], high[210000], low[210000];
bool in[210000], out[210000];
char s[210000];
long long ans;
void dp1(int x, int fa) {
  if (s[x] == '1') in[x] = 1;
  for (int k = fir[x]; k; k = a[k].nex) {
    int y = a[k].y;
    if (y == fa) continue;
    dp1(y, x);
    f[x] = max(f[x], f[y] + 1);
    in[x] |= in[y];
  }
}
void dp2(int x, int fa) {
  int mx1 = 0, mx2 = 0, cnt = 0;
  for (int k = fir[x]; k; k = a[k].nex) {
    int y = a[k].y;
    if (y == fa) continue;
    if (f[y] + 1 > mx1)
      mx2 = mx1, mx1 = f[y] + 1;
    else if (f[y] + 1 > mx2)
      mx2 = f[y] + 1;
    cnt += in[y];
  }
  for (int k = fir[x]; k; k = a[k].nex) {
    int y = a[k].y;
    if (y == fa) continue;
    if (f[y] + 1 == mx1)
      g[y] = max(g[x] + 1, mx2 + 1);
    else
      g[y] = max(g[x] + 1, mx1 + 1);
    out[y] = out[x];
    if (cnt - in[y]) out[y] = 1;
    dp2(y, x);
  }
}
void dfs(int x, int fa) {
  int mx1 = g[x], mx2 = 0;
  for (int k = fir[x]; k; k = a[k].nex) {
    int y = a[k].y;
    if (y == fa) continue;
    if (f[y] + 1 > mx1)
      mx2 = mx1, mx1 = f[y] + 1;
    else if (f[y] + 1 > mx2)
      mx2 = f[y] + 1;
  }
  if (mx2 == 0) mx2 = 1;
  high[x] = min(mx1 - 1, mx2);
  if (s[x] == '1')
    low[x] = 0;
  else {
    low[x] = high[x] + 1;
    if (out[x]) low[x] = min(low[x], g[x]);
    for (int k = fir[x]; k; k = a[k].nex) {
      int y = a[k].y;
      if (y == fa) continue;
      if (in[y]) low[x] = min(low[x], f[y] + 1);
    }
  }
  for (int k = fir[x]; k; k = a[k].nex) {
    int y = a[k].y;
    if (y == fa) continue;
    dfs(y, x);
  }
}
void ins(int x, int y) {
  a[++len].y = y;
  a[len].nex = fir[x];
  fir[x] = len;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    ins(x, y);
    ins(y, x);
  }
  scanf("%s", s + 1);
  dp1(1, 0);
  dp2(1, 0);
  dfs(1, 0);
  for (int i = 1; i <= n; i++) ans += high[i] - low[i] + 1;
  ans++;
  printf("%lld\n", ans);
  return 0;
}
