#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
vector<int> g[201000];
char s[201000];
int m1[201000], m2[201000], n, son[201000];
long long ans;
void dfs(int x, int fa) {
  m2[x] = -inf;
  m1[x] = -1;
  for (int v : g[x])
    if (v != fa) {
      dfs(v, x);
      if (m1[x] == m1[v]) son[x] = 0;
      if (m1[v] > m1[x])
        m2[x] = m1[x], m1[x] = m1[v], son[x] = v;
      else if (m1[v] > m2[x])
        m2[x] = m1[v];
    }
  ++m1[x], ++m2[x];
}
bool calc(int x, int fa, int upper) {
  int lower = (s[x] == '1' ? 0 : +inf);
  int mx = 0;
  for (int v : g[x])
    if (v != fa) {
      if (calc(v, x,
               (v != son[x] ? m1[v] + 1
                            : min(max(upper, m2[x] - 1) + 1, m1[v] + 1)))) {
        lower = min(lower, m1[v] + 1);
      }
      mx = m1[v] + 1;
    }
  if (fa == 0) upper = m1[x];
  if (lower <= upper) ans += upper - lower + 1;
  return lower != inf;
}
bool cmp(int i, int j) { return m1[i] < m1[j]; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  scanf("%s", s + 1);
  dfs(1, 0);
  for (int i = 1; i <= n; ++i) sort(g[i].begin(), g[i].end(), cmp);
  calc(1, 0, 0);
  if (g[1].size() == 1) --ans;
  printf("%lld\n", ans);
  return 0;
}
