#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n;
char s[N];
struct edge {
  int to, pre;
} e[N << 1];
int u[N], l = 0;
void ins(int a, int b) { e[++l] = (edge){b, u[a]}, u[a] = l; }
int f[N], g[N], high[N], low[N];
void dfs(int first, int fa) {
  if (s[first] == '1')
    low[first] = 0;
  else
    low[first] = n;
  for (int i = u[first]; i; i = e[i].pre)
    if (e[i].to != fa)
      dfs(e[i].to, first),
          f[first] = max(f[first], f[e[i].to] + 1),
          low[first] = min(low[first], max(f[e[i].to] + 1, low[e[i].to] + 1));
}
void dfs2(int first, int fa) {
  int mx = g[first], mxa = 0, mx1 = 0;
  for (int i = u[first]; i; i = e[i].pre)
    if (e[i].to != fa) {
      if (f[e[i].to] + 1 >= mx)
        mx1 = mx, mx = f[e[i].to] + 1, mxa = e[i].to;
      else if (f[e[i].to] + 1 > mx1)
        mx1 = f[e[i].to] + 1;
    }
  for (int i = u[first]; i; i = e[i].pre)
    if (e[i].to != fa) {
      if (e[i].to == mxa)
        g[e[i].to] = mx1 + 1,
        low[e[i].to] = min(low[e[i].to], max(low[first], mx1 + 1));
      else
        g[e[i].to] = mx + 1,
        low[e[i].to] = min(low[e[i].to], max(low[first], mx + 1));
    }
  static int a[N];
  int l = 0;
  a[++l] = g[first];
  for (int i = u[first]; i; i = e[i].pre)
    if (e[i].to != fa) a[++l] = f[e[i].to] + 1;
  sort(a + 1, a + l + 1);
  a[l + 1] = 0;
  high[first] = max(f[first], g[first]) - 1;
  high[first] = min(high[first], a[2] + 1);
  for (int i = u[first]; i; i = e[i].pre)
    if (e[i].to != fa) dfs2(e[i].to, first);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    ins(a, b), ins(b, a);
  }
  scanf("%s", s + 1);
  dfs(1, 0);
  dfs2(1, 0);
  long long ans = 1;
  for (int i = 1; i <= n; i++)
    if (low[i] <= high[i]) ans += high[i] - low[i] + 1;
  printf("%lld\n", ans);
  return 0;
}
