#include <bits/stdc++.h>
using namespace std;
struct data {
  int next, to;
  data(int next = 0, int to = 0) : next(next), to(to) {}
} edge[200005 << 1];
int n;
int fa[200005], a[200005], state[200005], maxd[200005];
int head[200005], cnt;
long long ans = 0;
void connect(int u, int v) {
  edge[++cnt] = data(head[u], v);
  head[u] = cnt;
}
void DFS(int u, int pre) {
  maxd[u] = 0;
  fa[u] = pre;
  for (int i = head[u]; i; i = edge[i].next) {
    int v = edge[i].to;
    if (v == pre) continue;
    DFS(v, u);
    maxd[u] = max(maxd[v] + 1, maxd[u]);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    connect(u, v);
    connect(v, u);
  }
  for (int i = 1; i <= n; ++i) scanf("%1d", &state[i]);
  DFS(1, 0);
  for (int i = 1; i <= n; ++i)
    ans += maxd[fa[i]] + 1 - (maxd[i] + 1 == maxd[fa[i]] && fa[i] == 1);
  printf("%lld\n", ans);
}
