#include <bits/stdc++.h>
using namespace std;
int N;
string S;
vector<int> E[202020];
int A[202020], B[202020];
signed long long ret = 0;
map<pair<int, int>, pair<int, int>> memo;
pair<int, int> dfs(int cur, int pre) {
  if (memo.count({cur, pre})) return memo[{cur, pre}];
  int D = 1;
  int is = S[cur];
  for (auto& r : E[cur])
    if (r != pre) {
      auto p = dfs(r, cur);
      D = max(D, p.first + 1);
      is |= p.second;
    }
  return memo[{cur, pre}] = make_pair(D, is);
}
void centerv(int a) {
  vector<pair<int, int>> V;
  V.push_back({0, S[a]});
  V.push_back({0, S[a]});
  for (auto& e : E[a]) {
    V.push_back(dfs(e, a));
  }
  sort((V.begin()), (V.end()));
  reverse((V.begin()), (V.end()));
  int Rmax = V[1].first;
  int Rmin = 201010;
  for (auto& v : V)
    if (v.second) Rmin = min(Rmin, v.first);
  if (Rmin <= Rmax) {
    ret += Rmax - Rmin + 1;
  }
}
void centere(int a, int b) {
  vector<pair<int, int>> V[2];
  V[0].push_back({0, S[a]});
  V[1].push_back({0, S[b]});
  int is[2] = {S[a], S[b]};
  for (auto& e : E[a])
    if (e != b) V[0].push_back(dfs(e, a)), is[0] |= V[0].back().second;
  for (auto& e : E[b])
    if (e != a) V[1].push_back(dfs(e, b)), is[1] |= V[1].back().second;
  sort((V[0].begin()), (V[0].end()));
  reverse((V[0].begin()), (V[0].end()));
  sort((V[1].begin()), (V[1].end()));
  reverse((V[1].begin()), (V[1].end()));
  if (V[0][0].first < V[1][0].first) {
    ret += is[0];
  } else if (V[0][0].first > V[1][0].first) {
    ret += is[1];
  } else {
    ret += is[0] | is[1];
  }
}
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N;
  for (i = 0; i < (N - 1); i++) {
    cin >> A[i] >> B[i];
    A[i]--, B[i]--;
    E[A[i]].push_back(B[i]);
    E[B[i]].push_back(A[i]);
  }
  cin >> S;
  for (auto& c : S) c -= '0';
  for (i = 0; i < (N); i++) centerv(i);
  for (i = 0; i < (N - 1); i++) centere(A[i], B[i]);
  cout << ret << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  solve();
  return 0;
}
