#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
constexpr int inf = 1000000010;
constexpr long long INF = 1000000000000000010;
constexpr long double eps = 1e-12;
constexpr long double pi = 3.141592653589793238;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n;
  cin >> n;
  vector<int> deg(n);
  vector<vector<int>> graph(n, vector<int>());
  for (long long i = 0; i < (n - 1); i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    graph[u].push_back(v);
    graph[v].push_back(u);
    deg[u]++;
    deg[v]++;
  }
  string s;
  cin >> s;
  vector<int> cnt(n);
  queue<int> que;
  for (long long i = 0; i < (n); i++)
    if (deg[i] == 1) {
      que.push(i);
      cnt[i] = 1;
    }
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (int i : graph[v]) {
      if (!cnt[i]) {
        cnt[i] = cnt[v] + 1;
        que.push(v);
      }
    }
  }
  int ans = n - 1;
  for (long long i = 0; i < (n); i++) ans += cnt[i];
  cout << ans << '\n';
}
