#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

typedef long long i64;
const int MAX_N = 200005;

class Edge {
public:
  int nxt, to;
} e[MAX_N << 1];

int head[MAX_N], cnt;
void addedge(int u, int v) {
  e[++cnt] = (Edge){head[u], v}, head[u] = cnt;
  e[++cnt] = (Edge){head[v], u}, head[v] = cnt;
}

int N;
char S[MAX_N];
int mx[MAX_N], smx[MAX_N], num[MAX_N], low[MAX_N];

void update(int x, int v) {
  if (mx[x] <= v) smx[x] = mx[x], mx[x] = v;
  else if (smx[x] < v) smx[x] = v;
}

void dfs1(int u, int v) {
  mx[u] = 0, num[u] = S[u], low[u] = N;
  for (int i = head[u]; i; i = e[i].nxt) 
    if (e[i].to != v) {
      dfs1(e[i].to, u);
      if (num[e[i].to]) low[u] = min(low[u], mx[e[i].to] + 1);
      num[u] += num[e[i].to];
      update(u, mx[e[i].to] + 1);
    }
}

void dfs2(int u, int v) {
  for (int i = head[u]; i; i = e[i].nxt)
    if (e[i].to != v) {
      int d;
      if (mx[u] == mx[e[i].to] + 1) {
	d = smx[u] + 1;
      } else {
	d = mx[u] + 1;
      }
      update(e[i].to, d);
      if (num[u] - num[e[i].to] > 0) low[e[i].to] = min(low[e[i].to], d);
      num[e[i].to] = num[u];
      dfs2(e[i].to, u);
    }
}

int main() {
  scanf("%d", &N);
  for (int i = 1, u, v; i < N; ++i) {
    scanf("%d%d", &u, &v);
    addedge(u, v);
  }
  
  scanf("%s", S + 1);
  for (int i = 1; i <= N; ++i) S[i] = S[i] - '0';
  
  dfs1(1, 0);
  dfs2(1, 0);

  i64 res = 0;
  for (int i = 1; i <= N; ++i) {
    int h = min(mx[i], smx[i] + 2);
    int l = S[i] ? 0 : low[i];

    res += max(0, h - l);
  }
  
  printf("%lld\n", res + 1);
  return 0;
}
