#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
inline long long getint() {
  long long _x = 0, _tmp = 1;
  char _tc = getchar();
  while ((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
  if (_tc == '-') _tc = getchar(), _tmp = -1;
  while (_tc >= '0' && _tc <= '9') _x *= 10, _x += (_tc - '0'), _tc = getchar();
  return _x * _tmp;
}
inline long long add(long long _x, long long _y,
                     long long _mod = 1000000007LL) {
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline long long sub(long long _x, long long _y,
                     long long _mod = 1000000007LL) {
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline long long mul(long long _x, long long _y,
                     long long _mod = 1000000007LL) {
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
long long mypow(long long _a, long long _x, long long _mod) {
  if (_x == 0) return 1LL;
  long long _ret = mypow(mul(_a, _a, _mod), _x >> 1, _mod);
  if (_x & 1) _ret = mul(_ret, _a, _mod);
  return _ret;
}
long long mymul(long long _a, long long _x, long long _mod) {
  if (_x == 0) return 0LL;
  long long _ret = mymul(add(_a, _a, _mod), _x >> 1, _mod);
  if (_x & 1) _ret = add(_ret, _a, _mod);
  return _ret;
}
inline bool equal(double _x, double _y) {
  return _x > _y - 1e-9 && _x < _y + 1e-9;
}
int __ = 1, _cs;
void build() {}
int n;
vector<int> v[202020];
char c[202020];
void init() {
  n = getint();
  for (int i = 1; i < n; i++) {
    int ai = getint();
    int bi = getint();
    v[ai].push_back(bi);
    v[bi].push_back(ai);
  }
  scanf("%s", c);
}
int mxdep[202020], root = 1;
vector<int> lmx[202020], rmx[202020];
void go(int now, int prt) {
  for (int son : v[now]) {
    if (son == prt) {
      lmx[now].push_back(0);
      rmx[now].push_back(0);
      continue;
    }
    go(son, now);
    lmx[now].push_back(mxdep[son] + 1);
    rmx[now].push_back(mxdep[son] + 1);
    mxdep[now] = max(mxdep[now], mxdep[son] + 1);
  }
  int sz = (int)lmx[now].size();
  for (int i = 1; i < sz; i++) lmx[now][i] = max(lmx[now][i], lmx[now][i - 1]);
  for (int i = sz - 2; i >= 0; i--)
    rmx[now][i] = max(rmx[now][i], rmx[now][i + 1]);
}
void go2(int now, int prt, int pmx) {
  mxdep[now] = max(mxdep[now], pmx);
  if (mxdep[now] < mxdep[root]) root = now;
  for (size_t i = 0; i < v[now].size(); i++) {
    int son = v[now][i];
    if (son == prt) continue;
    int tmx = pmx;
    if (i) tmx = max(tmx, lmx[now][i - 1]);
    if (i + 1 < v[now].size()) tmx = max(tmx, rmx[now][i + 1]);
    go2(son, now, tmx + 1);
  }
}
int ans, mndep[202020], mxd[202020];
vector<int> lmn[202020], rmn[202020];
void go3(int now, int prt) {
  mndep[now] = 202020;
  mxd[now] = 0;
  for (int son : v[now]) {
    if (son == prt) {
      lmn[now].push_back(202020);
      rmn[now].push_back(202020);
      continue;
    }
    go3(son, now);
    lmn[now].push_back(mndep[son] + 1);
    rmn[now].push_back(mndep[son] + 1);
    mndep[now] = min(mndep[now], mndep[son] + 1);
    mxd[now] = max(mxd[now], mxd[son] + 1);
  }
  if (mndep[now] == 202020) mndep[now] = 0;
  int sz = (int)lmn[now].size();
  for (int i = 1; i < sz; i++) lmn[now][i] = min(lmn[now][i], lmn[now][i - 1]);
  for (int i = sz - 2; i >= 0; i--)
    rmn[now][i] = min(rmn[now][i], rmn[now][i + 1]);
}
void go4(int now, int prt, int bdr) {
  int al = 0, ar = min(bdr, mxdep[now]);
  ar = max(ar, mxd[now]);
  ans += ar - al + 1;
  for (size_t i = 0; i < v[now].size(); i++) {
    int son = v[now][i];
    if (son == prt) continue;
    int tbdr = min(bdr + 1, ar);
    if (i) tbdr = min(tbdr, lmn[now][i - 1]);
    if (i + 1 < v[now].size()) tbdr = min(tbdr, rmn[now][i + 1]);
    go4(son, now, tbdr);
  }
}
void solve() {
  go(1, 1);
  go2(1, 1, 0);
  go3(root, root);
  go4(root, root, 202020);
  printf("%d\n", ans);
}
int main() {
  build();
  while (__--) {
    init();
    solve();
  }
}
