#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
const long long inf = 2e18, mod = 1e9 + 7;
int n, h[maxn];
vector<int> graph[maxn];
string s;
void dfs(int u, int prev = -1) {
  for (int i : graph[u])
    if (i != prev) {
      h[i] = h[u] + 1;
      dfs(i, u);
    }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    graph[--u].push_back(--v);
    graph[v].push_back(u);
  }
  cin >> s;
  for (int i = 0; i < n; i++)
    if (s[i] == '1') {
      dfs(i);
      cout << *max_element(h, h + n) + 1 << endl;
      return 0;
    }
}
