#include <bits/stdc++.h>
using namespace std;
const int MN = 200010;
int N;
vector<int> adj[MN];
char S[MN];
int dist[MN], par[MN];
long long ans;
void dfs0(int u, int p) {
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (v == p) continue;
    dist[v] = dist[u] + 1;
    par[v] = u;
    dfs0(v, u);
  }
}
int dfs1(int u, int p) {
  int ret = 0;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (v == p) continue;
    ret = max(ret, dfs1(v, u));
  }
  if (p == -1)
    ans += ret + 1;
  else
    ans += ret + 2;
  return ret + 1;
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N - 1; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  scanf("\n");
  for (int i = 0; i < N; i++) {
    scanf("%c", &S[i]);
  }
  if (N == 2) {
    printf("3");
    return 0;
  }
  dfs0(0, -1);
  int p = 0;
  for (int i = 0; i < N; i++)
    if (dist[p] < dist[i]) p = i;
  dist[p] = 0;
  dfs0(p, -1);
  for (int i = 0; i < N; i++)
    if (dist[p] < dist[i]) p = i;
  int root = p;
  while (dist[root] > dist[p] / 2) {
    root = par[root];
  }
  dfs1(root, -1);
  if (dist[p] % 2) ans--;
  printf("%lld", ans);
}
