#include <bits/stdc++.h>
struct {
  inline operator int() {
    int x;
    return scanf("%d", &x), x;
  }
  inline operator long long() {
    long long x;
    return scanf("%lld", &x), x;
  }
  template <class T>
  inline void operator()(T &x) {
    x = *this;
  }
  template <class T, class... A>
  inline void operator()(T &x, A &...a) {
    x = *this;
    this->operator()(a...);
  }
} read;
const int maxn = 200005;
int head[maxn], nxt[maxn << 1], to[maxn << 1], hp = 1;
char s[maxn];
inline void add(int u, int v) {
  nxt[++hp] = head[u];
  head[u] = hp;
  to[hp] = v;
}
struct Data {
  int d, d2, bd, bd2;
  inline void update(Data an) {
    if (an.d + 1 > d) {
      d2 = d;
      d = an.d + 1;
    } else
      d2 = std::max(d2, an.d + 1);
    if (an.bd + 1 < bd) {
      bd2 = bd;
      bd = an.bd + 1;
    } else
      bd2 = std::min(bd2, an.bd + 1);
  }
  inline void undo(Data an) {
    if (an.d + 1 == d) d = d2;
    if (an.bd + 1 == bd) bd = bd2;
  }
};
Data f[maxn];
void dfs1(int u, int fa) {
  f[u] = {1, 1, maxn, maxn};
  for (int i = head[u]; i; i = nxt[i]) {
    int v = to[i];
    if (v != fa) {
      dfs1(v, u);
      f[u].update(f[v]);
    }
  }
  if (s[u] == '1') f[u].bd = std::min(f[u].bd, f[u].d);
}
int ans = 1;
void dfs2(int u, int fa, Data ff) {
  Data g = f[u];
  g.update(ff);
  int L = s[u] == '1' ? 1 : g.bd;
  int R = std::min(g.d - 1, g.d2 + 1);
  if (L <= R) ans += R - L + 1;
  for (int i = head[u]; i; i = nxt[i]) {
    int v = to[i];
    if (v != fa) {
      Data vff = g;
      vff.undo(f[v]);
      dfs2(v, u, vff);
    }
  }
}
int main() {
  int n = read;
  for (int i = 1; i < n; i++) {
    int u = read, v = read;
    add(u, v);
    add(v, u);
  }
  scanf("%s", s + 1);
  dfs1(1, 0);
  dfs2(1, 0, {0, 0, maxn, maxn});
  printf("%d\n", ans);
}
