#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1.01e9;
const long long infll = (long long)1.01e18;
const long double eps = 1e-9;
const long double pi = acos((long double)-1);
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x) { return mrand() % x; }
void precalc() {}
const int maxn = (int)2e5 + 5;
int n;
vector<int> g[maxn];
int good[maxn];
char tmp[maxn];
bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    g[i].clear();
  }
  for (int i = 0; i < n - 1; i++) {
    int v, u;
    scanf("%d%d", &v, &u);
    v--;
    u--;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  scanf("%s", tmp);
  for (int i = 0; i < n; i++) {
    good[i] = tmp[i] - '0';
  }
  return true;
}
int d[maxn];
long long res;
int getFarthest(int v, int p) {
  int res = v;
  for (int i = 0; i < ((int)(g[v]).size()); i++) {
    int u = g[v][i];
    if (u == p) {
      continue;
    }
    d[u] = d[v] + 1;
    int cur = getFarthest(u, v);
    if (d[cur] > d[res]) {
      res = cur;
    }
  }
  return res;
}
bool getPath(int v, int t, int p, vector<int> &path) {
  path.push_back(v);
  if (v == t) {
    return true;
  }
  for (int i = 0; i < ((int)(g[v]).size()); i++) {
    int u = g[v][i];
    if (u == p) {
      continue;
    }
    if (getPath(u, t, v, path)) {
      return true;
    }
  }
  path.pop_back();
  return false;
}
vector<int> getCenter() {
  int v = 0;
  d[v] = 0;
  int u = getFarthest(v, -1);
  d[u] = 0;
  v = getFarthest(u, -1);
  vector<int> path;
  getPath(v, u, -1, path);
  if (((int)(path).size()) & 1) {
    return {path[((int)(path).size()) / 2]};
  } else {
    return {path[((int)(path).size()) / 2 - 1], path[((int)(path).size()) / 2]};
  }
}
bool dfs(int v, int p) {
  d[v] = 0;
  bool b = false;
  for (int i = 0; i < ((int)(g[v]).size()); i++) {
    int u = g[v][i];
    if (u == p) {
      continue;
    }
    if (dfs(u, v)) {
      b = true;
    }
    d[v] = max(d[v], d[u] + 1);
  }
  if (good[v]) {
    b = true;
    res += d[v] + 1;
  } else if (b) {
    res++;
  }
  if (p != -1 && b) {
    res++;
  }
  return b;
}
void solve() {
  res = 0;
  vector<int> vs = getCenter();
  if (((int)(vs).size()) == 2) {
    int v = vs[0], u = vs[1];
    g[v].erase(find(g[v].begin(), g[v].end(), u));
    g[u].erase(find(g[u].begin(), g[u].end(), v));
    bool b0 = dfs(v, -1);
    bool b1 = dfs(u, -1);
    if (b0 || b1) {
      res++;
    }
  } else {
    dfs(vs[0], -1);
  }
  printf("%lld\n", res);
}
int main() {
  precalc();
  while (read()) {
    solve();
  }
  return 0;
}
