#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n, reach[maxn], deep[maxn << 1], high[maxn], low[maxn];
int tote = 1, TO[maxn << 1], NEXT[maxn << 1], FIR[maxn];
bool col[maxn];
long long Ans = 1;
void addedge(int u, int v) {
  TO[++tote] = v;
  NEXT[tote] = FIR[u];
  FIR[u] = tote;
}
void dfs1(int u, int f) {
  for (int p = FIR[u]; p; p = NEXT[p]) {
    int v = TO[p];
    if (v == f) continue;
    dfs1(v, u);
    reach[u] = max(reach[u], reach[v] + 1);
    deep[p] = reach[v] + 1;
  }
}
void dfs2(int u, int f) {
  int mx = 0, se = 0;
  for (int p = FIR[u]; p; p = NEXT[p])
    if (mx < deep[p])
      se = mx, mx = deep[p];
    else if (se < deep[p])
      se = deep[p];
  high[u] = min(mx - 1, se + 1);
  for (int p = FIR[u]; p; p = NEXT[p]) {
    int v = TO[p];
    if (v == f) continue;
    deep[p ^ 1] = deep[p] == mx ? se + 1 : mx + 1;
    dfs2(v, u);
  }
}
int main() {
  int i, u, v;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    addedge(u, v);
    addedge(v, u);
  }
  for (i = 1; i <= n; i++) {
    char c = getchar();
    while (c != '0' && c != '1') c = getchar();
    col[i] = c == '1';
  }
  dfs1(1, 0);
  dfs2(1, 0);
  for (i = 1; i <= n; i++) Ans += high[i] + 1;
  printf("%lld\n", Ans);
}
