#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, m1[N], m2[N], sz[N], low[N];
char s[N];
long long ans;
int pp, lnk[N], nxt[N * 2], to[N * 2];
void ae(int k1, int k2) { to[++pp] = k2, nxt[pp] = lnk[k1], lnk[k1] = pp; }
void dfs(int k1, int k2) {
  sz[k1] = s[k1] & 15;
  if (s[k1] == '0') low[k1] = 0X3F3F3F3F;
  for (int i = lnk[k1]; i; i = nxt[i])
    if (to[i] != k2) {
      dfs(to[i], k1);
      if (m1[to[i]] + 1 > m1[k1])
        m2[k1] = m1[k1], m1[k1] = m1[to[i]] + 1;
      else
        m2[k1] = max(m2[k1], m1[to[i]] + 1);
      sz[k1] += sz[to[i]];
      if (sz[to[i]]) low[k1] = min(low[k1], m1[to[i]] + 1);
    }
}
void dfs2(int k1, int k2) {
  ans += max(0, min(m1[k1] - 1, m2[k1] + 1) - low[k1] + 1);
  for (int i = lnk[k1]; i; i = nxt[i])
    if (to[i] != k2) {
      int len = m1[k1] == m1[to[i]] + 1 ? m2[k1] + 1 : m1[k1] + 1;
      if (len > m1[to[i]])
        m1[to[i]] = len;
      else
        m2[to[i]] = max(m2[to[i]], len);
      if (sz[to[i]] < sz[1]) low[to[i]] = min(low[to[i]], len);
      dfs2(to[i], k1);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = (2); i <= (n); ++i) {
    int k1, k2;
    scanf("%d%d", &k1, &k2);
    ae(k1, k2), ae(k2, k1);
  }
  scanf("%s", s + 1);
  dfs(1, 0), dfs2(1, 0);
  printf("%lld\n", ans + 1);
  return 0;
}
