#include <bits/stdc++.h>
using namespace std;
int n, a[200005], d[200005], D[200005], U[200005], l[200005], r[200005];
vector<int> v[200005];
long long ans;
void dfs(int x, int y) {
  D[x] = d[x] = d[y] + 1;
  for (int i = 0; i < v[x].size(); ++i)
    if (v[x][i] != y) dfs(v[x][i], x), D[x] = max(D[x], D[v[x][i]]);
}
void dfs2(int x, int y) {
  int p = U[x], q;
  for (int i = 0; i < v[x].size(); ++i) {
    if (v[x][i] != y) {
      int o = D[v[x][i]] - d[x];
      if (o > p)
        q = p, p = o;
      else if (o > q)
        q = o;
    }
  }
  for (int i = 0; i < v[x].size(); ++i) {
    if (v[x][i] != y) {
      int o = D[v[x][i]] - d[x];
      if (o == p)
        U[v[x][i]] = q + 1;
      else
        U[v[x][i]] = p + 1;
      dfs2(v[x][i], x);
    }
  }
}
void dfs3(int x, int y) {
  if (a[x])
    l[x] = 0;
  else
    l[x] = r[x];
  for (int i = 0; i < v[x].size(); ++i) {
    int z = v[x][i];
    if (z != y) {
      dfs3(z, x);
      if (!a[x])
        l[x] = min(l[x], min(max(l[z] - 1, D[x] - d[x]), max(l[z] + 1, U[x])));
    }
  }
  ans += r[x] - l[x];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x].push_back(y), v[y].push_back(x);
  }
  for (int i = 1; i <= n; ++i) scanf("%1d", a + i);
  dfs(1, 0), dfs2(1, 0);
  r[1] = D[1] - 1;
  for (int i = 2; i <= n; ++i) r[i] = min(D[i] - d[i] + 2, U[i]);
  dfs3(1, 0);
  printf("%lld\n", ans + 1);
  return 0;
}
