#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  char c;
  for (c = getchar(); !isdigit(c); c = getchar())
    ;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
}
const int N = 2e5 + 50, oo = N;
char col[N];
int n, mxFi[N], mxSc[N], mnFi[N], mnSc[N];
long long ans;
vector<int> g[N];
void chkMx(int v, int w) {
  if (w > mxFi[v]) {
    mxSc[v] = mxFi[v], mxFi[v] = w;
  } else if (w > mxSc[v]) {
    mxSc[v] = w;
  }
}
void chkMn(int v, int w) {
  if (w < mnFi[v]) {
    mnSc[v] = mnFi[v], mnFi[v] = w;
  } else if (w < mnSc[v]) {
    mnSc[v] = w;
  }
}
void dp(int v, int p) {
  mxFi[v] = 1, mxSc[v] = 0;
  for (int d : g[v])
    if (d != p) {
      dp(d, v);
      chkMx(v, mxFi[d] + 1);
    }
}
void dp2(int v, int p) {
  mnFi[v] = col[v] == '1' ? mxFi[v] : oo, mnSc[v] = oo;
  for (int d : g[v])
    if (d != p) {
      dp2(d, v);
      chkMn(v, mnFi[d] + 1);
    };
}
void calc(int v, int p, int uMx, int uMn) {
  chkMx(v, uMx);
  chkMn(v, uMn);
  int lb = col[v] == '1' ? 1 : mnFi[v];
  ans += max(0, min(mxFi[v], mxSc[v] + 2) - lb);
  for (int d : g[v])
    if (d != p) {
      int mx, mn;
      if (mxFi[v] == mxFi[d] + 1)
        mx = mxSc[v] + 1;
      else
        mx = mxFi[v] + 1;
      if (mnFi[d] == mnFi[v] + 1)
        mn = mnSc[v] + 1;
      else
        mn = mnFi[v] + 1;
      calc(d, v, mx, mn);
    }
}
int main(int argc, char *argv[]) {
  read(n);
  for (int i = 1; i <= (n - 1); ++i) {
    int u, v;
    read(u), read(v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  scanf("%s", col + 1);
  dp(1, 0);
  dp2(1, 0);
  calc(1, 0, 0, oo);
  printf("%lld\n", ans + 1);
  return 0;
}
