#include <bits/stdc++.h>
using namespace std;
namespace Fenwick {
int c[200010];
void add(int x, int v) {
  while (x < 200010) {
    c[x] += v;
    x += x & (-x);
  }
}
int sum(int x) {
  int res = 0;
  while (x) {
    res += c[x];
    x -= x & (-x);
  }
  return res;
}
}  // namespace Fenwick
struct edge {
  int to, next;
  edge(int _to = 0, int _next = 0) : to(_to), next(_next) {}
} e[200010 << 1];
int n;
int g[200010], nume, deg[200010];
int pre[200010], w[200010][2], numw;
int d[200010], d2[200010], d3[200010], d4[200010];
char type[200010];
long long ans;
void addEdge(int u, int v) {
  e[nume] = edge(v, g[u]);
  g[u] = nume++;
}
void dfs(int x, int p) {
  w[x][0] = ++numw;
  d[x] = 0;
  d3[x] = n + 1;
  pre[x] = p;
  for (int i = g[x]; ~i; i = e[i].next)
    if (e[i].to ^ p) {
      dfs(e[i].to, x);
      d[x] = max(d[x], d[e[i].to] + 1);
      d3[x] = min(d3[x], d3[e[i].to] + 1);
    }
  if (d3[x] == n + 1) d3[x] = 0;
  w[x][1] = numw;
}
void dfs2(int x, int p) {
  pair<int, int> td1(-1, 0), td2(-1, 0);
  pair<int, int> td3(n + 1, 0), td4(n + 1, 0);
  if (p)
    td3 = td1 = make_pair(d2[x], 0);
  else
    d4[x] = n + 1;
  for (int i = g[x]; ~i; i = e[i].next)
    if (e[i].to ^ p) {
      pair<int, int> temp = make_pair(d[e[i].to], e[i].to);
      if (temp > td1)
        td2 = td1, td1 = temp;
      else if (temp > td2)
        td2 = temp;
      if (temp < td3)
        td4 = td3, td3 = temp;
      else if (temp < td4)
        td4 = temp;
    }
  for (int i = g[x]; ~i; i = e[i].next)
    if (e[i].to ^ p) {
      if (e[i].to == td1.second)
        d2[e[i].to] = td2.first + 1;
      else
        d2[e[i].to] = td1.first + 1;
      if (e[i].to == td3.second)
        d4[e[i].to] = td4.first + 1;
      else
        d4[e[i].to] = td3.first + 1;
      dfs2(e[i].to, x);
    }
}
void gao(int x) {
  static pair<int, int> b[200010];
  int numb = 0;
  for (int i = g[x]; ~i; i = e[i].next)
    if (e[i].to ^ pre[x])
      b[++numb] =
          make_pair(d[e[i].to] + 1, Fenwick::sum(w[e[i].to][1]) -
                                        Fenwick::sum(w[e[i].to][0] - 1));
  if (pre[x])
    b[++numb] = make_pair(d2[x] + 1, Fenwick::sum(n) - Fenwick::sum(w[x][1]) +
                                         Fenwick::sum(w[x][0] - 1));
  sort(b + 1, b + numb + 1);
  for (int i = 1; i <= numb; i++) {
    int temp = (i == numb) ? b[numb - 1].first : b[numb].first;
    if (temp > b[i].first - 2 && b[i].second) ans++;
  }
}
int main() {
  memset(g, -1, sizeof g);
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    addEdge(u, v);
    addEdge(v, u);
    deg[u]++;
    deg[v]++;
  }
  scanf("%s", type + 1);
  dfs(1, 0);
  dfs2(1, 0);
  ans++;
  for (int i = 1; i <= n; i++)
    if (type[i] == '1') {
      Fenwick::add(w[i][0], 1);
      if (deg[i] > 1)
        ans += min(d3[i], d4[i] + 1);
      else
        ans++;
    }
  for (int i = 1; i <= n; i++) gao(i);
  printf("%lld\n", ans);
  return 0;
}
