#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T &res) {
  res = 0;
  T f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    res = res * 10 + c - '0';
    c = getchar();
  }
  res *= f;
}
template <class T>
void out(T x) {
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  if (x >= 10) {
    out(x / 10);
  }
  putchar('0' + x % 10);
}
struct node {
  int to, next;
} E[200005 * 2];
int N, head[200005], sumE, dep[200005], fr[200005], high[200005], low[200005];
char s[200005];
void add(int u, int v) {
  E[++sumE].to = v;
  E[sumE].next = head[u];
  head[u] = sumE;
}
void dfs1(int u, int fa) {
  for (int i = head[u]; i; i = E[i].next) {
    int v = E[i].to;
    if (v != fa) {
      dfs1(v, u);
      dep[u] = max(dep[u], dep[v] + 1);
    }
  }
}
void dfs2(int u, int fa) {
  vector<int> vec;
  dep[u] = max(dep[u], fr[u] + 1);
  vec.push_back(1);
  if (fa) vec.push_back(fr[u] + 2);
  pair<int, int> p = make_pair(0, 0);
  for (int i = head[u]; i; i = E[i].next) {
    int v = E[i].to;
    if (v != fa) {
      vec.push_back(dep[v] + 2);
      if (dep[v] > dep[p.second]) p.second = v;
      if (dep[p.second] > dep[p.first]) swap(p.first, p.second);
    }
  }
  sort(vec.begin(), vec.end());
  high[u] = dep[u] - 1;
  vec.pop_back();
  high[u] = min(high[u], vec.back());
  vec.clear();
  for (int i = head[u]; i; i = E[i].next) {
    int v = E[i].to;
    if (v != fa) {
      fr[v] = max(fr[v], fr[u] + 1);
      if (v != p.first) fr[v] = max(fr[v], dep[p.first] + 1);
      if (v != p.second) fr[v] = max(fr[v], dep[p.second] + 1);
    }
  }
  for (int i = head[u]; i; i = E[i].next) {
    int v = E[i].to;
    if (v != fa) {
      dfs2(v, u);
    }
  }
}
void Solve() {
  read(N);
  int a, b;
  for (int i = 1; i < N; ++i) {
    read(a);
    read(b);
    add(a, b);
    add(b, a);
  }
  scanf("%s", s + 1);
  dep[0] = -1;
  fr[1] = -1;
  dfs1(1, 0);
  dfs2(1, 0);
  long long ans = 1;
  for (int i = 1; i <= N; ++i) {
    ans += high[i] + 1;
  }
  out(ans);
  putchar('\n');
}
int main() {
  Solve();
  return 0;
}
