#include <bits/stdc++.h>
using namespace std;
int n, f[200010], g[200010];
char s[200010];
vector<int> a[200010];
long long p = 1;
inline void dp(int i, int j) {
  int k;
  f[i] = 1;
  g[i] = s[i - 1] - '0';
  for (k = 0; k < a[i].size(); k++)
    if (a[i][k] != j) {
      dp(a[i][k], i);
      f[i] = max(f[i], f[a[i][k]] + 1);
      g[i] += g[a[i][k]];
    }
}
inline void dp2(int i, int j, int b, int c) {
  int k, u, v, w, d = 0;
  if (i == 1)
    u = v = w = 0;
  else {
    u = b;
    v = 0;
    if (c) w = b;
  }
  b++;
  c += s[i - 1] - '0';
  for (k = 0; k < a[i].size(); k++)
    if (a[i][k] != j) {
      if (f[a[i][k]] > u)
        v = u, u = f[a[i][k]];
      else
        v = max(v, f[a[i][k]]);
      if (g[i]) w = min(w, f[a[i][k]]);
      if (f[a[i][k]] + 1 > b)
        d = b, b = f[a[i][k]] + 1;
      else
        d = max(d, f[a[i][k]] + 1);
      c += g[a[i][k]];
    }
  u = min(u - 1, v + 1);
  if (s[i - 1] == '1') w = 0;
  p += max(u - w + 1, 0);
  for (k = 0, u = b, v = c; k < a[i].size(); k++)
    if (a[i][k] != j)
      dp2(a[i][k], i, (f[a[i][k]] + 1 == b) ? d : b, c - g[a[i][k]]);
}
int main() {
  int i, j, k;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d%d", &j, &k);
    a[j].push_back(k);
    a[k].push_back(j);
  }
  scanf("%s", &s);
  dp(1, 0);
  dp2(1, 0, 0, 0);
  cout << p << "\n";
  return 0;
}
