#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define popcount __builtin_popcount
#define all(a) (a).begin(), (a).end()
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
template<typename T> using ordered_set = tree<T,null_type,less_equal<>,rb_tree_tag,tree_order_statistics_node_update>;
const int N = 200000;
vector<int> adj[N];
string gen;
int dfs(int u, int p = -1) {
int res = 0;
for (int v : adj[u]) {
if (v != p) res += dfs(v, u);
}
return max(0 + gen[u], res - gen[u]);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n; cin >> n;
for (int i = 0, u, v; i < n-1; i++) {
cin >> u >> v;
adj[--u].push_back(--v);
adj[v].push_back(u);
}
cin >> gen;
int anas = 0;
for (int i = 0; i < n; i++) {
anas = max(anas, dfs(i));
for (int j : adj[i]) {
anas = max(anas, dfs(j, i) + gen[i]);
}
}
cout << anas;
}