#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
const int maxn = 310000;
vector<int> e[maxn];
int d[maxn][2], dup[maxn];
int rad[maxn];
int dth[maxn];
string s;
void add(int *m, int x) {
  for (int i = 0; i < (int)(2); ++i)
    if (x > m[i]) swap(x, m[i]);
}
int max_exc(int *m, int x) {
  for (int i = 0; i < (int)(2); ++i) {
    if (m[i] == x)
      x = -1;
    else
      return m[i];
  }
  return -1;
}
void dfs_d(int v, int p) {
  for (int u : e[v]) {
    if (u == p) continue;
    dfs_d(u, v);
    add(d[v], max_exc(d[u], -1) + 1);
  }
}
void dfs_up(int v, int p, int D) {
  dup[v] = D;
  for (int u : e[v]) {
    if (u == p) continue;
    dfs_up(u, v, max(D, max_exc(d[v], d[u][0] + 1) + 1) + 1);
  }
}
long long ans;
int dfs_C(int v, int p) {
  dth[v] = 0;
  int minq = s[v] == '1' ? 0 : 1e9;
  for (int u : e[v]) {
    if (u == p) continue;
    uin(minq, dfs_C(u, v) - 1);
    uax(dth[v], dth[u] + 1);
  }
  int sk = max(0, min(rad[v] - 1, dth[v] + 1) - minq + 1);
  ans += sk;
  minq += sk;
  return minq;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  int n;
  cin >> n;
  for (int i = 0; i < (int)(n - 1); ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  cin >> s;
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(2); ++j) d[i][j] = -1;
  dfs_d(0, -1);
  dfs_up(0, -1, -1e9);
  for (int i = 0; i < (int)(n); ++i)
    rad[i] = max(dup[i], max_exc(d[i], -1) + 1);
  int C = 0;
  for (int i = 0; i < (int)(n); ++i)
    if (rad[i] < rad[C]) C = i;
  ans = 1;
  dfs_C(C, -1);
  cout << ans << '\n';
  return 0;
}
