#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 200007;
int n;
long long ans;
vector<int> e[MAXN];
char s[MAXN];
bool cho[MAXN];
int lev[MAXN];
int aml[MAXN];
void init();
void input();
void work();
int dfs1(int now, int fa);
void dfs2(int now, int fa, int al);
bool dfs(int now, int fa, int nl, int al, int vu);
int main() {
  init();
  input();
  work();
}
void init() { ios::sync_with_stdio(false); }
void input() {
  scanf("%d", &n);
  int u, v;
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &u, &v);
    e[u].push_back(v), e[v].push_back(u);
  }
  scanf("%s", s);
}
void work() {
  for (int i = 1; i <= n; ++i) cho[i] = s[i - 1] == '1';
  if (n == 2) {
    int cc = 0;
    for (int i = 1; i <= n; ++i) cc += cho[i];
    cout << ((cc == 1) ? 2 : 3) << endl;
    return;
  }
  dfs1(1, -1);
  dfs2(1, -1, 0);
  int rt = min_element(aml + 1, aml + 1 + n) - aml;
  dfs1(rt, -1);
  dfs(rt, -1, 0, -1, -MAXN);
  ++ans;
  cout << ans << endl;
}
int dfs1(int now, int fa) {
  lev[now] = 0;
  for (auto v : e[now])
    if (v ^ fa) lev[now] = max(lev[now], dfs1(v, now) + 1);
  return lev[now];
}
void dfs2(int now, int fa, int al) {
  aml[now] = (((lev[now]) > (al)) ? (lev[now]) : (al));
  int maxi = -1, sm = -1;
  for (auto v : e[now]) {
    if (v ^ fa) {
      if (lev[v] > maxi)
        sm = maxi, maxi = lev[v];
      else if (lev[v] > sm)
        sm = lev[v];
    }
  }
  for (auto v : e[now])
    if (v ^ fa) dfs2(v, now, max(al, ((lev[v] == maxi) ? sm : maxi) + 1) + 1);
}
bool dfs(int now, int fa, int nl, int al, int vu) {
  if (~fa) e[now].erase(find(e[now].begin(), e[now].end(), fa));
  if (e[now].empty()) {
    if (cho[now])
      ans += (((al + nl) < ((nl - vu) * 2)) ? (al + nl) : ((nl - vu) * 2));
    return cho[now];
  }
  sort(e[now].begin(), e[now].end(),
       [](int x, int y) { return lev[x] < lev[y]; });
  bool nch = false;
  if (al == -1) al = lev[now];
  if (cho[now]) {
    ans +=
        (((al + nl) < ((nl - vu) * 2 + lev[now])) ? (al + nl)
                                                  : ((nl - vu) * 2 + lev[now]));
    if (!nch) {
      nch = true;
      vu = (((vu) > (nl)) ? (vu) : (nl));
    }
  }
  for (auto v : e[now]) {
    if (fa == -1 && v == e[now].back()) al = lev[*(e[now].rbegin() + 1)] + 1;
    if (dfs(v, now, nl + 1, al, vu) && !nch) {
      nch = true;
      vu = (((vu) > (nl)) ? (vu) : (nl));
    }
  }
  return nch;
}
