#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
inline void judge() {
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
}
const int maxn = 200005;
int head[maxn], t[maxn << 1], ne[maxn << 1], num, n;
int dp[maxn], nr[maxn];
char s[maxn];
long long ans = 0;
inline void dfs1(int x, int f) {
  dp[x] = 0;
  nr[x] = n;
  if (s[x] == '1') nr[x] = 0;
  for (int i = head[x]; i != -1; i = ne[i])
    if (t[i] != f) {
      dfs1(t[i], x);
      dp[x] = max(dp[x], dp[t[i]] + 1);
      nr[x] = min(nr[x], nr[t[i]] + 1);
    }
}
inline void dfs2(int x, int f, int n1, int dp1) {
  int maxi1 = 0, nd1 = 0, maxi2 = 0, nd2 = 0, tot = 0;
  maxi1 = dp1;
  nd1 = n1;
  vector<int> son;
  for (int i = head[x]; i != -1; i = ne[i])
    if (t[i] != f) {
      tot++;
      son.push_back(t[i]);
      if (dp[t[i]] + 1 > maxi1) {
        maxi2 = maxi1;
        nd2 = nd1;
        maxi1 = dp[t[i]] + 1;
        nd1 = nr[t[i]] + 1;
      } else if (dp[t[i]] + 1 > maxi2) {
        maxi2 = dp[t[i]] + 1;
        nd2 = nr[t[i]] + 1;
      }
    }
  if (s[x] == '1') ans += min(maxi1 - 1, maxi2 + nd1) + 1;
  vector<int> dpprmax(tot + 2, 0), dpsfmax(tot + 2, 0), nrprmin(tot + 2, n),
      nrsfmin(tot + 2, n);
  for (int i = (1); i <= (tot); i++) {
    dpprmax[i] = max(dpprmax[i - 1], dp[son[i - 1]] + 2);
    nrprmin[i] = min(nrprmin[i - 1], nr[son[i - 1]] + 2);
  }
  for (int i = (tot); i >= (1); i--) {
    dpsfmax[i] = max(dpsfmax[i + 1], dp[son[i - 1]] + 2);
    nrsfmin[i] = min(nrsfmin[i + 1], nr[son[i - 1]] + 2);
  }
  if (s[x] == '1') n1 = 0;
  for (int i = (1); i <= (tot); i++) {
    dfs2(son[i - 1], x, min(n1 + 1, min(nrprmin[i - 1], nrsfmin[i + 1])),
         max(max(dp1 + 1, dpprmax[i - 1]), dpsfmax[i + 1]));
  }
}
inline void addedge(int x, int y) {
  ne[++num] = head[x];
  head[x] = num;
  t[num] = y;
  ne[++num] = head[y];
  head[y] = num;
  t[num] = x;
}
int main() {
  read(n);
  for (int i = (1); i <= (n); i++) head[i] = -1;
  for (int i = (1); i <= (n - 1); i++) {
    int x, y;
    read(x);
    read(y);
    addedge(x, y);
  }
  scanf("%s", s + 1);
  dfs1(1, -1);
  dfs2(1, -1, n, 0);
  ans++;
  printf("%lld\n", ans);
  return 0;
}
