#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n;
char s[N];
vector<int> v[N];
class dat {
 public:
  int mx1, mx2;
  void update(int v) {
    if (v > mx1) {
      mx2 = mx1;
      mx1 = v;
    } else if (v > mx2)
      mx2 = v;
  }
} d[N], dg[N];
void dfs1(int np, int fath) {
  for (int &x : v[np]) {
    if (x == fath) continue;
    dfs1(x, np);
    d[np].update(d[x].mx1 + 1);
  }
}
void dfs2(int np, int fath, int dfa) {
  d[np].update(dfa + 1);
  vector<int> ch;
  ch.push_back(0);
  for (int &x : v[np]) {
    if (x == fath) continue;
    ch.push_back(x);
  }
  ch.push_back(0);
  vector<int> pre(ch.size()), suf(ch.size());
  for (int i = 1; i + 1 < pre.size(); i++)
    pre[i] = max(pre[i - 1], d[ch[i]].mx1 + 1);
  for (int i = suf.size() - 2; i >= 1; i--)
    suf[i] = max(suf[i + 1], d[ch[i]].mx1 + 1);
  for (int i = 1; i + 1 < ch.size(); i++)
    dfs2(ch[i], np, max(dfa + 1, max(pre[i - 1], suf[i + 1])));
}
int main() {
  scanf("%d", &n);
  for (int i = 1, ti, tj; i < n; i++) {
    scanf("%d%d", &ti, &tj);
    v[ti].push_back(tj);
    v[tj].push_back(ti);
  }
  scanf("%s", s + 1);
  dfs1(1, 0);
  dfs2(1, 0, -1e9);
  long long ans = 1;
  for (int i = 1; i <= n; i++) {
    int l = (s[i] == '0' ? 0 : 0), r = min(d[i].mx1, d[i].mx2 + 2);
    if (l < r) ans += r - l;
  }
  printf("%lld\n", ans);
  return 0;
}
