#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T &x) {
  int f = 0;
  x = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar()) f |= (ch == '-');
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  if (f) x = -x;
}
const int N = 200005;
int f[N], from[N], d[N], q[N], n, a, b, rt, rt2;
char s[N];
vector<int> e[N];
long long ans;
void diameter() {
  int r = 0, u;
  fill(d, d + n + 1, -1);
  d[1] = 0, q[r++] = 1;
  for (int l = 0; l < r; l++) {
    u = q[l];
    for (int k = 0; k < (((int)e[u].size())); k++) {
      if (d[e[u][k]] == -1) {
        d[e[u][k]] = d[u] + 1;
        q[r++] = e[u][k];
      }
    }
  }
  fill(d, d + n + 1, -1), r = 0;
  d[u] = 0, q[r++] = u;
  for (int l = 0; l < r; l++) {
    u = q[l];
    for (int k = 0; k < (((int)e[u].size())); k++) {
      if (d[e[u][k]] == -1) {
        d[e[u][k]] = d[u] + 1;
        from[e[u][k]] = u;
        q[r++] = e[u][k];
      }
    }
  }
  vector<int> pt;
  for (; u; u = from[u]) {
    pt.push_back(u);
  }
  if (((int)pt.size()) & 1) {
    rt = pt[((int)pt.size()) / 2];
  } else {
    rt = pt[((int)pt.size()) / 2 - 1];
    rt2 = pt[((int)pt.size()) / 2];
  }
}
void dfs(int u, int fa) {
  d[u] = 0, f[u] = N;
  for (int k = 0; k < (((int)e[u].size())); k++) {
    int v = e[u][k];
    if (v == fa) continue;
    dfs(v, u);
    d[u] = max(d[u], d[v] + 1);
    ans += max(0, d[v] + 2 - f[v]);
    f[u] = min(f[u], d[v] + 1);
  }
  if (s[u] == '1') {
    f[u] = 0;
  }
}
int main() {
  read(n);
  for (int i = (1); i <= (n - 1); i++) {
    read(a), read(b);
    e[a].push_back(b), e[b].push_back(a);
  }
  scanf("%s", s + 1);
  diameter();
  if (!rt2) {
    dfs(rt, 0);
    ans += max(0, d[rt] - f[rt]);
  } else {
    dfs(rt, rt2);
    ans += max(0, d[rt] - f[rt] + 1);
    dfs(rt2, rt);
    ans += max(0, d[rt2] - f[rt2] + 1);
  }
  cout << ans + 1 << endl;
  return 0;
}
