#include <bits/stdc++.h>
using namespace std;
int i, j, m, n, p, k, Max[200005], CMax[200005], fa[200005], x, y, High[200005];
vector<int> v[200005];
char c[200005];
void dfs(int x) {
  int i;
  for (i = 0; i < (int)v[x].size(); ++i) {
    int p = v[x][i];
    if (fa[x] == p) continue;
    fa[p] = x;
    dfs(p);
    if (Max[p] + 1 > Max[x])
      swap(Max[x], CMax[x]), Max[x] = Max[p] + 1;
    else if (Max[p] + 1 > CMax[x])
      CMax[x] = CMax[p] + 1;
  }
}
void Count_high(int x, int y) {
  int i;
  High[x] = max(Max[x], y) - 1;
  High[x] = min(High[x], Max[x] + 1);
  for (i = 0; i < (int)v[x].size(); ++i) {
    int p = v[x][i];
    if (fa[x] == p) continue;
    Count_high(p, max(y, (Max[x] == Max[p] + 1) ? CMax[x] : Max[x]) + 1);
    int pre = max(y, (Max[x] == Max[p] + 1) ? CMax[x] : Max[x]) + 1;
    High[x] = min(High[x], pre);
  }
}
int main() {
  scanf("%d", &n);
  if (n == 1) {
    puts("1");
    return 0;
  }
  for (i = 1; i < n; ++i) {
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  scanf("%s", c + 1);
  dfs(1);
  Count_high(1, 0);
  long long s = 1;
  for (i = 1; i <= n; ++i) s += High[i] + 1;
  cout << s << endl;
}
