#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
const long long INF = 1e18;
long long power(long long x, long long y) {
  long long t = 1;
  while (y > 0) {
    if (y % 2)
      y -= 1, t = t * x % mod;
    else
      y /= 2, x = x * x % mod;
  }
  return t;
}
vector<int> G[N];
char s[N];
int mx[N], sub[N], mn[N];
void dfs(int v, int p) {
  sub[v] = 0;
  for (int i = 0; i < G[v].size(); ++i)
    if (G[v][i] != p) {
      dfs(G[v][i], v);
      sub[v] = max(sub[v], sub[G[v][i]] + 1);
    }
}
void dfs1(int v, int p, int l) {
  pair<int, int> arr[2];
  memset(arr, 0, sizeof(arr));
  arr[0] = make_pair(l, p);
  for (int i = 0; i < G[v].size(); ++i)
    if (G[v][i] != p) {
      pair<int, int> z = make_pair(sub[G[v][i]] + 1, G[v][i]);
      if (z > arr[0])
        arr[1] = arr[0], arr[0] = z;
      else
        arr[1] = max(arr[1], z);
    }
  mx[v] = min(arr[0].first - 1, arr[1].first + 1);
  for (int i = 0; i < G[v].size(); ++i)
    if (G[v][i] != p) {
      if (G[v][i] != arr[0].second)
        dfs1(G[v][i], v, arr[0].first + 1);
      else
        dfs1(G[v][i], v, arr[1].first + 1);
    }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  scanf("%s", s);
  dfs(0, -1);
  dfs1(0, -1, 0);
  long long ans = 1;
  for (int i = 0; i < n; ++i) ans += mx[i] + 1;
  printf("%lld\n", ans);
  return 0;
}
