#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -f;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  x *= f;
}
vector<int> a[200005];
int l[200005], r[200005], size[200005], n;
int mx[200005], home[200005], nx[200005];
char s[200005];
void updmin(int &x, int y) { x = min(x, y); }
void updmax(int &x, int y) { x = max(x, y); }
void update(int x, int y) {
  int value;
  if (home[y] == x)
    value = nx[y] + 1;
  else
    value = mx[y] + 1;
  if (value > mx[x]) {
    nx[x] = mx[x];
    mx[x] = value;
    home[x] = y;
  } else
    updmax(nx[x], value);
}
void dfs1(int pos, int fa) {
  size[pos] = s[pos] == '1';
  if (size[pos]) updmin(l[pos], 0);
  for (unsigned i = 0; i < a[pos].size(); i++)
    if (a[pos][i] != fa) {
      dfs1(a[pos][i], pos);
      update(pos, a[pos][i]);
      size[pos] += size[a[pos][i]];
      if (size[a[pos][i]]) updmin(l[i], mx[a[pos][i]] + 1);
    }
}
void dfs2(int pos, int fa) {
  for (unsigned i = 0; i < a[pos].size(); i++)
    if (a[pos][i] != fa) {
      update(a[pos][i], pos);
      dfs2(a[pos][i], pos);
      if (size[1] - size[a[pos][i]]) {
        if (home[pos] == a[pos][i])
          updmin(l[a[pos][i]], nx[pos] + 1);
        else
          updmin(l[a[pos][i]], mx[pos] + 1);
      }
    }
  r[pos] = min(mx[pos] - 1, nx[pos] + 1);
}
int main() {
  read(n);
  for (int i = 1; i < n; i++) {
    int x, y;
    read(x), read(y);
    a[x].push_back(y);
    a[y].push_back(x);
  }
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) l[i] = 1e9;
  dfs1(1, 0);
  dfs2(1, 0);
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    if (r[i] >= l[i]) ans += r[i] - l[i] + 1;
  cout << ans + 1 << endl;
  return 0;
}
