#include <bits/stdc++.h>
using namespace std;
long long n;
vector<long long> G[200005];
vector<pair<long long, long long> > E;
string s;
map<pair<long long, long long>, long long> mp;
void dfs(int v, int p) {
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if (u == p) continue;
    dfs(u, v);
    long long mx = 0;
    for (int j = 0; j < G[u].size(); j++) {
      if (G[u][j] == v) continue;
      mx = max(mx, mp[make_pair(u, G[u][j])]);
    }
    mp[make_pair(v, u)] = mx + 1;
  }
}
long long lmx[200005], rmx[200005];
void dfs2(int v, int p) {
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if (u == p) {
      if (i > 0) lmx[i] = lmx[i - 1];
      continue;
    }
    lmx[i] = mp[make_pair(v, u)];
    if (i > 0) lmx[i] = max(lmx[i], lmx[i - 1]);
  }
  for (int i = (int)G[v].size() - 1; i >= 0; i--) {
    int u = G[v][i];
    if (u == p) {
      if (i < (int)G[v].size() - 1) rmx[i] = rmx[i + 1];
      continue;
    }
    rmx[i] = mp[make_pair(v, u)];
    if (i < (int)G[v].size() - 1) rmx[i] = max(rmx[i], rmx[i + 1]);
  }
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if (u == p) continue;
    long long mx = 0;
    if (i > 0) mx = max(mx, lmx[i - 1]);
    if (i < (int)G[v].size() - 1) mx = max(mx, rmx[i + 1]);
    mp[make_pair(u, v)] = mx + 1;
  }
  for (int i = 0; i < G[v].size(); i++) {
    if (G[v][i] == p) continue;
    dfs2(G[v][i], v);
  }
}
int main(void) {
  cin >> n;
  long long u, v;
  for (int i = 1; i <= n - 1; i++) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
    E.push_back(make_pair(u, v));
  }
  cin >> s;
  s = "#" + s;
  dfs(1, -1);
  dfs2(1, -1);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans++;
    vector<long long> vec;
    if (G[i].size() <= 1) continue;
    for (int j = 0; j < G[i].size(); j++)
      vec.push_back(mp[make_pair(i, G[i][j])]);
    sort(vec.rbegin(), vec.rend());
    ans += min(vec[0], vec[1]);
  }
  ans += n - 1;
  cout << ans << endl;
  return 0;
}
