#include <bits/stdc++.h>
using namespace std;
const int Max_N(200050);
int N, Head[Max_N], Total, To[Max_N << 1], Next[Max_N << 1], Size[Max_N],
    F1[Max_N], F2[Max_N];
char B[Max_N];
long long int Ans;
inline void Add_Edge(int s, int t) {
  ++Total, To[Total] = t, Next[Total] = Head[s], Head[s] = Total;
}
void dfs(int u, int fa) {
  Size[u] = B[u] - '0';
  for (int i = Head[u], v; i; i = Next[i])
    if ((v = To[i]) != fa) {
      dfs(v, u), Size[u] += Size[v];
      if (F1[v] + 1 >= F1[u])
        F2[u] = F1[u], F1[u] = F1[v] + 1;
      else if (F1[v] + 1 >= F2[u])
        F2[u] = F1[v] + 1;
    }
}
void work(int u, int fa) {
  int l, r;
  l = (B[u] == '1' ? 0 : N + 1);
  if (fa != -1) {
    int d = (F1[fa] == F1[u] + 1 ? F2[fa] : F1[fa]);
    l = min(l, d + 1);
    if (d + 1 >= F1[u])
      F2[u] = F1[u], F1[u] = d + 1;
    else if (d + 1 >= F2[u])
      F2[u] = d + 1;
  }
  r = min(F1[u], F2[u] + 2);
  for (int i = Head[u], v; i; i = Next[i])
    if ((v = To[i]) != fa) {
      if (Size[v]) l = min(l, F1[v] + 1);
      work(v, u);
    }
  if (l <= r - 1) Ans += r - l;
}
int main() {
  scanf("%d", &N);
  for (int i = 1, u, v; i != N; ++i)
    scanf("%d%d", &u, &v), Add_Edge(u, v), Add_Edge(v, u);
  scanf("%s", B + 1);
  dfs(1, -1), work(1, -1);
  printf("%lld", Ans + 1LL);
  return 0;
}
