#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, mx[N], second[N];
vector<int> e[N];
char s[N];
long long ans;
inline void upd(int x, int u) {
  if (u > mx[x])
    second[x] = mx[x], mx[x] = u;
  else if (u > second[x])
    second[x] = u;
}
void dfs1(int x, int fa) {
  for (int v : e[x])
    if (v != fa) dfs1(v, x), upd(x, mx[v] + 1);
}
void dfs2(int x, int fa) {
  if (fa) upd(x, mx[x] + 1 == mx[fa] ? second[fa] + 1 : mx[fa] + 1);
  for (int v : e[x])
    if (v != fa) dfs2(v, x);
  ans += min(second[x] + 2, mx[x]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1, u, v; i < n; i++)
    scanf("%d%d", &u, &v), e[u].push_back(v), e[v].push_back(u);
  scanf("%s", s + 1);
  dfs1(1, 0);
  dfs2(1, 0);
  printf("%lld\n", ans + 1);
  return 0;
}
