#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const int maxn = 200010;
int n, first[maxn], nxt[maxn << 1], to[maxn << 1], e;
void AddEdge(int u, int v) {
  to[++e] = v;
  nxt[e] = first[u];
  first[u] = e;
  to[++e] = u;
  nxt[e] = first[v];
  first[v] = e;
}
int f[maxn], g[maxn], mx[maxn], se[maxn], siz[maxn], size;
char s[maxn];
void dfsin(int x, int fa) {
  siz[x] = 1;
  for (int i = first[x]; i; i = nxt[i])
    if (to[i] != fa) {
      dfsin(to[i], x);
      f[x] = max(f[x], f[to[i]] + 1);
      if (f[to[i]] + 1 > se[x]) se[x] = f[to[i]] + 1;
      if (se[x] > mx[x]) swap(mx[x], se[x]);
      siz[x] += siz[to[i]];
    }
}
void dfsout(int x, int fa) {
  for (int i = first[x]; i; i = nxt[i])
    if (to[i] != fa) {
      g[to[i]] = max(f[to[i]] + 1 == mx[x] ? se[x] : mx[x], g[x]) + 1;
      dfsout(to[i], x);
    }
}
long long solve(int x, int fa) {
  if (g[x] > se[x]) se[x] = g[x];
  if (se[x] > mx[x]) swap(mx[x], se[x]);
  long long ans = 0;
  for (int i = first[x]; i; i = nxt[i])
    if (to[i] != fa) ans += solve(to[i], x);
  return ans + min(mx[x], se[x] + 2);
}
int main() {
  n = read();
  for (int i = (2), i_end_ = (n); i <= i_end_; i++) AddEdge(read(), read());
  scanf("%s", s + 1);
  dfsin(1, 0);
  dfsout(1, 0);
  for (int i = (1), i_end_ = (n); i <= i_end_; i++)
    if (s[i] == '1') size++;
  printf("%lld\n", solve(1, 0) + 1);
  return 0;
}
