#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
const int inf = 0x7f7f7f7f;
int read() {
  int x = 0, flag = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * flag;
}
char str[maxn];
int n, cnte;
int head[maxn], to[maxn * 2], nxt[maxn * 2];
int vis[maxn], Max1[maxn], Max2[maxn], dep[maxn], dis[maxn];
int v1[maxn], v2[maxn], siz[maxn];
int low[maxn], height[maxn];
void AddEdge(int x, int y) {
  ++cnte;
  to[cnte] = y;
  nxt[cnte] = head[x];
  head[x] = cnte;
}
int Dfs(int x, int fa) {
  int flag = vis[x];
  siz[x] = vis[x];
  Max1[x] = Max2[x] = 0;
  dis[x] = inf;
  dep[x] = 0;
  for (int i = head[x]; i; i = nxt[i])
    if (to[i] ^ fa) {
      int tmp = Dfs(to[i], x);
      flag |= tmp;
      siz[x] = siz[x] + tmp;
      if (tmp) dis[x] = min(dep[to[i]] + 1, dis[x]);
      dep[x] = max(dep[to[i]] + 1, dep[x]);
      if (Max1[x] == 0 || dep[to[i]] > dep[Max1[x]]) {
        Max2[x] = Max1[x];
        Max1[x] = to[i];
      } else if (Max2[x] == 0 || dep[to[i]] > dep[Max2[x]])
        Max2[x] = to[i];
    }
  return flag;
}
void dfs(int x, int fa, int Lim, bool flag) {
  int t1 = dep[Max1[x]] + 1, t2 = dep[Max2[x]] + 1;
  if (Max1[x] == 0) t1 = 0;
  if (Max2[x] == 0) t2 = 0;
  if (Lim > t1) {
    t2 = t1;
    t1 = Lim;
  } else if (Lim > t2)
    t2 = Lim;
  height[x] = min(t2 + 1, t1 - 1);
  if (!vis[x])
    low[x] = min(dis[x], (flag ? Lim : inf));
  else
    low[x] = 0;
  for (int i = head[x]; i; i = nxt[i])
    if (to[i] ^ fa) {
      if (to[i] == Max1[x])
        dfs(to[i], x, max(Lim, dep[Max2[x]] + 1) + 1,
            (bool)(siz[x] - siz[to[i]]) | flag);
      else
        dfs(to[i], x, max(Lim, dep[Max1[x]] + 1) + 1,
            (bool)(siz[x] - siz[to[i]]) | flag);
    }
}
int main() {
  n = read();
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    x = read();
    y = read();
    AddEdge(x, y);
    AddEdge(y, x);
  }
  scanf("%s", str + 1);
  for (int i = 1; i <= n; i++)
    if (str[i] == '1') vis[i] = 1;
  Dfs(1, 0);
  dfs(1, 0, 0, 0);
  int Ans = 0;
  for (int i = 1; i <= n; i++) {
    if (low[i] <= height[i]) Ans += height[i] - low[i] + 1;
  }
  printf("%d\n", Ans + 1);
  return 0;
}
