#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T& x) {
  char c;
  int sign = 1;
  x = 0;
  do {
    c = getchar();
    if (c == '-') sign = -1;
  } while (!isdigit(c));
  do {
    x = x * 10 + c - '0';
    c = getchar();
  } while (isdigit(c));
  x *= sign;
}
const int N = 2e5 + 50;
int head[N], to[N << 1], nxt[N << 1], tot;
inline void add(int x, int y) {
  to[tot] = y;
  nxt[tot] = head[x];
  head[x] = tot++;
}
char s[N];
int dep[N], mi[N], mx[N], se[N], n;
void dfs1(int x, int fa) {
  dep[x] = se[x] = 1;
  for (register int i = head[x]; ~i; i = nxt[i])
    if (to[i] != fa) {
      dfs1(to[i], x);
      if (dep[x] < dep[to[i]] + 1)
        dep[x] = dep[to[i]] + 1;
      else if (dep[se[x]] < dep[to[i]] + 1)
        se[x] = to[i] + 1;
    }
}
int ans = 0;
void dfs2(int x, int fa) {
  for (register int i = head[x]; ~i; i = nxt[i])
    if (to[i] != fa) {
      if (to[i] != se[x])
        mx[to[i]] = min(dep[to[i]] + 1, se[x] + 1);
      else
        mx[to[i]] = dep[to[i]] + 1;
      dfs2(to[i], x);
    }
  mi[fa] = min(mi[fa], dep[x] + 1);
  ans += max(mx[x] - mi[x] + 1, 0);
}
int main() {
  memset(head, -1, sizeof head);
  read(n);
  for (register int i = 2; i <= n; ++i) {
    int u, v;
    read(u);
    read(v);
    add(u, v);
    add(v, u);
  }
  scanf("%s", s + 1);
  for (register int i = 1; i <= n; ++i) mi[i] = s[i] == '1' ? 1 : n + 1;
  dfs1(1, 1);
  mx[1] = dep[1];
  dfs2(1, 1);
  cout << ans << endl;
  return 0;
}
