#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v[200005];
int dep[200005];
void dfs(int first, int f) {
  for (auto &it : v[first]) {
    if (it.second != f) {
      dfs(it.second, first);
      it.first = dep[it.second] + 1;
    }
  }
  sort(v[first].begin(), v[first].end());
  reverse(v[first].begin(), v[first].end());
  if (f != 0 && v[first].size() == 1)
    ;
  else
    dep[first] = v[first][0].first;
}
void dfs2(int first, int f, int sum) {
  for (auto it : v[first]) {
    if (it.second != f) {
      if (it.first == v[first][0].first) {
        if (v[first].size() == 1) {
          dfs2(it.second, first, sum + 1);
        } else {
          dfs2(it.second, first, max(v[first][1].first, sum) + 1);
        }
      } else {
        dfs2(it.second, first, max(v[first][0].first, sum) + 1);
      }
    }
  }
  if (f != 0) {
    v[first].back().first = sum;
  }
}
int val[200005];
int l[200005];
int d[200005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int first, second;
    scanf("%d %d", &first, &second);
    v[first].push_back(make_pair(-1, second));
    v[second].push_back(make_pair(-1, first));
    d[first]++;
    d[second]++;
  }
  dfs(1, 0);
  dfs2(1, 0, 0);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    sort(v[i].begin(), v[i].end());
    reverse(v[i].begin(), v[i].end());
    if (v[i].size() == 1) {
      val[i] = 2;
      v[i].push_back(make_pair(0, 0));
      if (v[i][0].first == 1) val[i]--;
    } else {
      val[i] = v[i][1].first + 2;
      if (v[i][1].first == v[i][0].first) val[i] -= 2;
      if (v[i][1].first == v[i][0].first - 1) val[i]--;
    }
  }
  char c[200005];
  scanf("%s", c + 1);
  queue<int> q;
  for (int i = 1; i <= n; i++) {
    if (c[i] == '1') {
      q.push(i);
      l[i] = 0;
    } else {
      l[i] = 1e9;
    }
    if (v[i].size() == 1) q.push(i);
    d[i]--;
    val[i]--;
  }
  while (!q.empty()) {
    int first = q.front();
    q.pop();
    if (v[v[first][0].second][0].second == first) {
    } else {
      if (--d[v[first][0].second] == 0) {
        q.push(v[first][0].second);
      }
    }
    if (c[first] == '1') {
      l[v[first][0].second] = min(l[v[first][0].second], v[first][1].first + 1);
    } else {
      l[v[first][0].second] = min(l[v[first][0].second], l[first] + 1);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (val[i] >= l[i]) ans += val[i] - l[i] + 1;
  }
  printf("%lld\n", ans + 1);
}
