#include <bits/stdc++.h>
using namespace std;
const int MAX = 1 << 18;
int dist_down[MAX], dist_up[MAX];
vector<int> V[MAX];
vector<int> Ld[MAX], Rd[MAX];
int poz_par[MAX], par[MAX];
char s[MAX];
void dfs_down(int node, int pr) {
  par[node] = pr;
  for (auto it = V[node].begin(); it != V[node].end(); it++)
    if (*it == pr) {
      V[node].erase(it);
      break;
    }
  Ld[node].push_back(0);
  for (auto it : V[node]) {
    dfs_down(it, node);
    poz_par[it] = (int)Ld[node].size();
    Ld[node].push_back(max(Ld[node].back(), dist_down[it] + 1));
  }
  dist_down[node] = Ld[node].back();
  Rd[node].push_back(0);
  for (int i = (int)V[node].size() - 1; i >= 0; i--) {
    int it = V[node][i];
    Rd[node].push_back(max(Rd[node].back(), dist_down[it] + 1));
  }
  reverse(Rd[node].begin(), Rd[node].end());
}
pair<int, int> presjek(pair<int, int> a, pair<int, int> b) {
  return pair<int, int>(max(a.first, b.first), min(a.second, b.second));
}
long long rje = 0;
void dfs_up(int node, int pr) {
  if (pr != -1) {
    dist_up[node] = 1 + max(dist_up[pr], max(Ld[pr][poz_par[node] - 1],
                                             Rd[pr][poz_par[node]]));
  }
  pair<int, int> pres =
      pair<int, int>(0, max(dist_down[node], dist_up[node]) - 1);
  if (pr != -1) {
    if (dist_down[node] > dist_up[node] - 1)
      pres = presjek(pres, pair<int, int>(0, dist_up[node] - 1));
    else if (dist_down[node] < dist_up[node] - 1)
      pres = presjek(pres, pair<int, int>(0, dist_down[node] + 1));
  }
  rje += max(0, pres.second - pres.first + 1);
  for (auto it : V[node]) dfs_up(it, node);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    V[a].push_back(b);
    V[b].push_back(a);
  }
  scanf(" %s", s);
  dfs_down(0, -1);
  dfs_up(0, -1);
  rje++;
  printf("%lld\n", rje);
  return 0;
}
