#include <bits/stdc++.h>
long long gi() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) f ^= ch == '-', ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f ? x : -x;
}
char S[200010];
int fir[200010], dis[400010], nxt[400010], id;
void link(int a, int b) { nxt[++id] = fir[a], fir[a] = id, dis[id] = b; }
std::vector<int> pre[200010], suf[200010];
int F[200010];
void dfs(int x, int fa = -1) {
  for (int i = fir[x]; i; i = nxt[i]) {
    if (fa == dis[i]) continue;
    dfs(dis[i], x);
    pre[x].push_back(F[dis[i]] + 1);
  }
  suf[x] = pre[x];
  for (int i = 1; i < pre[x].size(); ++i)
    pre[x][i] = std::max(pre[x][i], pre[x][i - 1]);
  for (int i = suf[x].size() - 2; i >= 0; --i)
    suf[x][i] = std::max(suf[x][i], suf[x][i + 1]);
  if (!pre[x].empty()) F[x] = suf[x][0];
}
long long ans;
void DFS(int x, int FF = 0, int fa = -1) {
  int mx = FF, cm = 0;
  for (int i = fir[x]; i; i = nxt[i]) {
    if (fa == dis[i]) continue;
    if (F[dis[i]] + 1 > mx)
      cm = mx, mx = F[dis[i]] + 1;
    else
      cm = std::max(cm, F[dis[i]] + 1);
  }
  ans += std::min(mx, cm + 2);
  for (int i = fir[x], j = 0; i; i = nxt[i], ++j) {
    if (fa == dis[i]) continue;
    int df = FF;
    if (j) df = std::max(df, pre[x][j - 1]);
    if (j + 1 < suf[x].size()) df = std::max(df, suf[x][j + 1]);
    DFS(dis[i], df + 1, x);
  }
}
int main() {
  int n = gi(), u, v;
  for (int i = 1; i < n; ++i) u = gi(), v = gi(), link(u, v), link(v, u);
  scanf("%s", S + 1);
  dfs(1);
  DFS(1);
  printf("%lld\n", ans + 1);
  return 0;
}
