#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;
const long long Inf = 1e10;
const int P = 1e9 + 7;
const int N = 200005;
inline long long IN() {
  long long x = 0;
  int ch = 0, f = 0;
  for (ch = getchar(); ch != -1 && (ch < 48 || ch > 57); ch = getchar())
    f = (ch == '-');
  for (; ch >= 48 && ch <= 57; ch = getchar())
    x = (x << 1) + (x << 3) + ch - '0';
  return f ? (-x) : x;
}
template <typename T>
inline int chkmin(T &a, const T &b) {
  if (b < a) return a = b, 1;
  return 0;
}
template <typename T>
inline int chkmax(T &a, const T &b) {
  if (b > a) return a = b, 1;
  return 0;
}
void renew(int &x, const int &y) {
  x += y;
  if (x >= P) x -= P;
  if (x < 0) x += P;
}
int Pow(int x, int y, int p) {
  int a = 1;
  for (; y; y >>= 1, x = (long long)x * x % p)
    if (y & 1) a = (long long)a * x % p;
  return a;
}
int n;
int mxd[N], sed[N], mad[N], gg[N], hev[N];
struct edge {
  int v, pre;
} e[N << 1];
int dex, adj[N];
int fa[N];
void dfs(int x) {
  for (int i = adj[x]; i; i = e[i].pre) {
    int v = e[i].v;
    if (v == fa[x]) continue;
    fa[v] = x;
    dfs(v);
    if (mxd[v] + 1 > mxd[x]) {
      sed[x] = mxd[x];
      hev[x] = v;
      mxd[x] = mxd[v] + 1;
    } else if (mxd[v] + 1 > sed[x]) {
      sed[x] = mxd[v] + 1;
    }
  }
}
void dp(int x) {
  for (int i = adj[x]; i; i = e[i].pre) {
    int v = e[i].v;
    if (v == fa[x]) continue;
    if (v == hev[x]) {
      gg[v] = max(gg[x], sed[x]) + 1;
    } else {
      gg[v] = max(gg[x], mxd[x]) + 1;
    }
    dp(v);
  }
}
int hg[N], lo[N], ans = 1;
char s[N];
void work(int x, int par) {
  mad[x] = 0;
  if (s[x] == '1')
    lo[x] = 0;
  else
    lo[x] = 1 << 30;
  for (int i = adj[x]; i; i = e[i].pre) {
    int v = e[i].v;
    if (v == par) continue;
    work(v, x);
    mad[x] = max(mad[x], mad[v] + 1);
    lo[x] = min(lo[x], lo[v] - 1);
  }
  hg[x] = min(mad[x] + 1, mxd[x] - 1);
  ans += max(0, hg[x] - lo[x] + 1);
  lo[x] = max(lo[x], hg[x] + 1);
}
int main() {
  scanf("%d", &n);
  for (int i = (int)(1); i <= (int)(n - 1); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[++dex] = (edge){y, adj[x]};
    adj[x] = dex;
    e[++dex] = (edge){x, adj[y]};
    adj[y] = dex;
  }
  dfs(1);
  dp(1);
  for (int i = (int)(1); i <= (int)(n); i++) mxd[i] = max(mxd[i], gg[i]);
  int rt = min_element(mxd + 1, mxd + n + 1) - mxd;
  scanf("%s", s + 1);
  work(rt, 0);
  printf("%d\n", ans);
  return 0;
}
