#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 7;
const int INF = 1e9 + 7;
template <class T>
inline T rd() {
  bool f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = 0;
  T x = 0;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
  return f ? x : -x;
}
int n;
int depth[maxN];
int sz[maxN], tot;
long long ans;
char s[maxN];
struct Vec {
  static const int maxE = maxN;
  int g[maxN], te;
  struct edge {
    int y, nxt;
  } e[maxE << 1];
  inline void push(int x, int y) {
    e[++te] = (edge){y, g[x]};
    g[x] = te;
  }
  inline void link(int x, int y) { push(x, y), push(y, x); }
  inline int& operator()(int x) { return g[x]; }
  inline edge& operator[](int x) { return e[x]; }
} e;
void dfs1(int x, int fa) {
  depth[x] = 1;
  sz[x] = s[x] == '1';
  for (int p = e(x), y = e[p].y; p; y = e[p = e[p].nxt].y)
    if (y != fa) {
      dfs1(y, x);
      depth[x] = max(depth[x], depth[y] + 1);
      sz[x] += sz[y];
    }
}
void dfs2(int x, int fa) {
  int mx = 0, sec = 0, id = 0, least = s[x] == '1' ? 0 : INF;
  for (int p = e(x), y = e[p].y; p; y = e[p = e[p].nxt].y) {
    if (depth[y] > mx)
      mx = depth[y], id = y;
    else if (depth[y] > sec)
      sec = depth[y];
    if (s[x] == '0' && sz[y]) least = min(least, depth[y]);
  }
  ans += max(0, min(mx - 1, sec + 1) - least + 1);
  for (int p = e(x), y = e[p].y; p; y = e[p = e[p].nxt].y)
    if (y != fa) {
      sz[x] = tot - sz[y];
      if (y != id)
        depth[x] = mx + 1, dfs2(y, x);
      else
        depth[x] = sec + 1, dfs2(y, x);
    }
}
int main() {
  n = rd<int>();
  for (int i = (1), _ = (n); i < _; ++i) e.link(rd<int>(), rd<int>());
  scanf("%s", s + 1);
  for (int i = (1), _ = (n); i <= _; ++i)
    if (s[i] == '1') ++tot;
  dfs1(1, 0);
  dfs2(1, 0);
  printf("%lld\n", ans + 1);
  return 0;
}
