#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using ld = long double;
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[";
  for (ll i = ll(0); i < ll((ll)v.size()); i++) {
    if (i) os << ",";
    os << v[i];
  }
  os << "]";
  return os;
}
ll read() {
  ll i;
  scanf("%lld", &i);
  return i;
}
void printSpace() { printf(" "); }
void printEoln() { printf("\n"); }
void print(ll x, ll suc = 1) {
  printf("%lld", x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}
string readString() {
  static char buf[3341919];
  scanf("%s", buf);
  return string(buf);
}
char* readCharArray() {
  static char buf[3341919];
  static ll bufUsed = 0;
  char* ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}
template <class T, class U>
void chmax(T& a, U b) {
  if (a < b) a = b;
}
template <class T, class U>
void chmin(T& a, U b) {
  if (a > b) a = b;
}
template <class T>
T Sq(const T& t) {
  return t * t;
}
const ll Nmax = 214514;
ll dep[Nmax];
vi g[Nmax];
ll dia;
void dfs1(ll v, ll p) {
  for (auto c : g[v])
    if (c != p) {
      dfs1(c, v);
      chmax(dep[v], dep[c] + 1);
    }
}
ll ans;
void dfs2(ll v, ll p, ll w) {
  {
    vi dist;
    dist.push_back(w);
    dist.push_back(0);
    for (auto c : g[v])
      if (c != p) dist.push_back(dep[c] + 1);
    sort(dist.begin(), dist.end(), greater<ll>());
    if (ll(dist.size()) >= 2) {
      ans += dist[1];
      if (dist[0] > dist[1]) ans++;
    }
    chmax(dia, dist[0] + dist[1]);
  }
  {
    vi dist;
    dist.push_back(w);
    for (auto c : g[v])
      if (c != p) dist.push_back(dep[c] + 1);
    sort(dist.begin(), dist.end(), greater<ll>());
    for (auto c : g[v])
      if (c != p) {
        if (dep[c] + 1 != dist[0])
          dfs2(c, v, dist[0] + 1);
        else
          dfs2(c, v, dist[1] + 1);
      }
  }
}
signed main() {
  ll n = read();
  for (ll _ = ll(0); _ < ll(n - 1); _++) {
    ll a = read() - 1, b = read() - 1;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  string s = readString();
  for (auto c : s) assert(c == '1');
  dfs1(0, -1);
  dfs2(0, -1, 0);
  ans += n;
  if (dia & 1) ans--;
  cout << ans << endl;
}
