#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
const long long M = 1000000007;
vector<int> G[200010];
vector<pair<int, int> > dp_ord;
vector<int> dep[200010];
vector<int> cnt[200010];
bool s_[200010];
void make_ord_dfs1(int v, int p) {
  for (int i = 0; i < G[v].size(); i++) {
    if (G[v][i] != p) {
      make_ord_dfs1(G[v][i], v);
      dp_ord.push_back(pair<int, int>(v, i));
    }
  }
}
void make_ord_dfs2(int v, int p) {
  for (int i = 0; i < G[v].size(); i++) {
    if (G[v][i] == p) {
      dp_ord.push_back(pair<int, int>(v, i));
      break;
    }
  }
  for (int i = 0; i < G[v].size(); i++) {
    if (G[v][i] != p) {
      make_ord_dfs2(G[v][i], v);
    }
  }
}
void make_ord() {
  make_ord_dfs1(1, 0);
  make_ord_dfs2(1, 0);
}
void dfs(int v, int id) {
  int u = G[v][id];
  dep[v][id] = 0;
  cnt[v][id] = 0;
  for (int i = 0; i < G[u].size(); i++) {
    if (G[u][i] == v) continue;
    dep[v][id] = max(dep[v][id], dep[u][i]);
    cnt[v][id] += cnt[u][i];
  }
  dep[v][id]++;
  if (s_[u]) cnt[v][id]++;
}
int main() {
  static int n;
  static int a[200010], b[200010];
  string s;
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) scanf("%d%d", &a[i], &b[i]);
  cin >> s;
  for (int i = 1; i <= n - 1; i++) {
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
    dep[a[i]].push_back(-1);
    cnt[a[i]].push_back(-1);
    dep[b[i]].push_back(-1);
    cnt[b[i]].push_back(-1);
  }
  for (int i = 1; i <= n; i++) {
    if (s[i - 1] == '1')
      s_[i] = true;
    else
      s_[i] = false;
  }
  make_ord();
  for (pair<int, int> p : dp_ord) {
    dfs(p.first, p.second);
  }
  long long ret = 0;
  for (int i = 1; i <= n; i++) {
    vector<pair<int, int> > vec;
    for (int j = 0; j < G[i].size(); j++) {
      vec.push_back(pair<int, int>(dep[i][j], cnt[i][j]));
    }
    vec.push_back(pair<int, int>(0, (s_[i] ? 1 : 0)));
    sort(vec.begin(), vec.end());
    int d_max = vec[vec.size() - 1].first;
    int k = vec.size() - 1;
    while (k > 0 && vec[k].first == d_max) k--;
    int I = 0;
    while (I + 1 < vec.size() && vec[I].second == 0) I++;
    ret += max(min(d_max, vec[k].first + 2) - vec[I].first, 0);
  }
  cout << ret + 1 << endl;
}
