#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 100;
vector<int> g[N];
char s[N];
int d[N];
void dfs(int v, int par, int cd) {
  d[v] = cd;
  for (int to : g[v]) {
    if (to == par) continue;
    dfs(to, v, cd + 1);
  }
}
struct Ans {
  int maxd;
  int l;
  Ans() : maxd(), l() {}
  Ans(int _maxd, int _l) : maxd(_maxd), l(_l) {}
};
long long answer = 0;
int n;
int mx;
Ans solve(int v, int par) {
  vector<Ans> ch;
  for (int to : g[v]) {
    if (to == par) continue;
    ch.push_back(solve(to, v));
  }
  int mxd = 0;
  for (auto ans : ch) {
    mxd = max(mxd, ans.maxd);
  }
  42;
  int curl = n + 10;
  for (auto ans : ch) {
    curl = min(curl, ans.l);
  }
  if (s[v] == '1') curl = 0;
  int curmx = (mx + 1) / 2 + d[v];
  if (curmx + mxd > mx) curmx--;
  42;
  int nl = max(curl, mxd + 2);
  nl = min(max(curmx, mxd), nl);
  answer += max(nl - curl, 0);
  42;
  42;
  42;
  42;
  return Ans(mxd + 1, nl - 1);
}
int main(int, char **) {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  scanf("%s", s);
  for (int i = 0; i < n; i++)
    if (s[i] == '1') {
      answer++;
      break;
    }
  int v = 0;
  for (int it = 0; it < 2; it++) {
    dfs(v, v, 0);
    for (int i = 0; i < n; i++)
      if (d[i] > d[v]) v = i;
  }
  mx = d[v];
  42;
  for (int i = 0; i < n; i++)
    if (d[i] == d[v] / 2) {
      v = i;
      break;
    }
  dfs(v, v, 0);
  Ans ans = solve(v, v);
  42;
  printf("%lld\n", answer);
  return 0;
}
