#include <bits/stdc++.h>

using namespace std;

int read() {
  int res = 0; char c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)) res = res * 10 + c - '0', c = getchar();
  return res;
}

void read(char *S) {
  char *s = S, c = getchar();
  while(c != '0' && c != '1') c = getchar();
  while(c == '0' || c == '1') *s = c, s++, c = getchar();
}

typedef long long ll;
const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;

int head[maxn], nxt[maxn << 1], to[maxn << 1], e_cnt;
void link(int u, int v) {
  nxt[++e_cnt] = head[u], head[u] = e_cnt, to[e_cnt] = v;
  nxt[++e_cnt] = head[v], head[v] = e_cnt, to[e_cnt] = u;
}

int mx[maxn], se[maxn], d[maxn], sz[maxn], n;
char S[maxn];
long long Ans;

void dfs_1(int x, int fa) {
  if(S[x] == '1') d[x] = 0, sz[x] = 1;
  else d[x] = inf;
  for(int i = head[x]; i; i = nxt[i]) {
    int y = to[i];
    if(y == fa) continue;
    dfs_1(y, x), sz[x] += sz[y];
    if(mx[y] + 1 > mx[x]) se[x] = mx[x], mx[x] = mx[y] + 1;
    else if(mx[y] + 1 > se[x]) se[x] = mx[y] + 1;
    if(sz[y]) d[x] = min(d[x], mx[y] + 1);
  }
}

void dfs_2(int x, int fa) {
  int R = min(se[x] + 1, mx[x] - 1);
  if(d[x] <= R) Ans += 1LL * (R - d[x] + 1);
  for(int i = head[x]; i; i = nxt[i]) {
    int y = to[i];
    if(y == fa) continue;
    int kl = (mx[y] + 1 == mx[x] ? se[x] + 1 : mx[x] + 1);
    if(kl > mx[y]) se[y] = mx[y], mx[y] = kl;
    else if(kl > se[y]) se[y] = kl;
    if(sz[1] - sz[y]) d[y] = min(d[y], kl);
    dfs_2(y, x);
  }
}

int main() {
  n = read();
  for(int i = 2; i <= n; i++) link(read(), read());
  read(S + 1);
  dfs_1(1, 0);
  dfs_2(1, 0);
  printf("%lld\n", Ans + 1);
}
