#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, sz, pos[N], m1[N], m2[N], low[N], b[N];
long long ans;
char s[N];
struct edge {
  int y, nex;
} g[N * 2];
void init(int x, int y) { g[++sz] = (edge){y, pos[x]}, pos[x] = sz; }
void dfs1(int x, int fa) {
  low[x] = n + 1;
  if (s[x] == '1') b[x]++, low[x] = 0;
  for (int i = pos[x]; i; i = g[i].nex)
    if (g[i].y != fa) {
      dfs1(g[i].y, x);
      b[x] += b[g[i].y];
      int z = m1[g[i].y] + 1;
      if (m1[x] < z)
        m2[x] = m1[x], m1[x] = z;
      else
        m2[x] = max(m2[x], z);
      low[x] = min(low[x], z);
    }
}
void dfs2(int x, int fa) {
  for (int i = pos[x]; i; i = g[i].nex)
    if (g[i].y != fa) {
      int z;
      if (m1[x] == m1[g[i].y] + 1)
        z = m2[x] + 1;
      else
        z = m1[x] + 1;
      if (m1[g[i].y] < z)
        m2[g[i].y] = m1[g[i].y], m1[g[i].y] = z;
      else
        m2[g[i].y] = max(m2[g[i].y], z);
      if (b[g[i].y] < b[1]) low[g[i].y] = min(low[g[i].y], z);
      dfs2(g[i].y, x);
    }
  int z = min(m2[x] + 1, m1[x] - 1);
  if (z >= low[x]) ans += z - low[x] + 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    init(x, y), init(y, x);
  }
  scanf("%s", s + 1);
  dfs1(1, 0);
  dfs2(1, 0);
  printf("%d\n", ans + 1);
  return 0;
}
