#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
template <bool Directed, typename TEdge, bool Index> struct graph {
    using EType = TEdge;
    vector<TEdge> edges;
    vector<vector<int>> adj;
    graph(int n) : adj(n + Index) {}
    graph(int n, int m) : graph(n) { edges.reserve(m << not Directed); }
    TEdge& operator()(int e) { return edges[e]; }
    vector<int>& operator[](int u) { return adj[u]; }
    int size() { return adj.size() - Index; }
    void add_edge(const TEdge& e) {
        adj[e.u].push_back(edges.size());
        edges.push_back(e);
        if(not Directed) {
            adj[e.v].push_back(edges.size());
            edges.push_back(e.reverse());
        }
    }
};
struct edge {
    int u, v;
    edge reverse() const { return {v, u}; }
    friend ostream& operator<<(ostream& os, const edge& e) {
        return os << "(" << e.u << ", " << e.v << ")";
    }
};
template <typename T> using f = function<T>;
template <typename TEdge> struct dfs_params {
    f<void(int)> pre_node{[](int) -> void {}};
    f<void(int)> pos_node{[](int) -> void {}};
    f<void(TEdge&)> pre_edge{[](TEdge&) -> void {}};
    f<void(TEdge&)> pos_edge{[](TEdge&) -> void {}};
    int root = 0;
};
template <bool Directed, typename TEdge, bool Index, typename TParamsetter = f<void(dfs_params<TEdge>&)>>
vector<int> dfs(graph<Directed, TEdge, Index>& g, const TParamsetter& psetter = [](dfs_params<TEdge>&) {}) {
    static_assert(is_convertible<decltype(psetter), f<void(dfs_params<TEdge>&)>>::value, "psetter must be void(dfs_params<TEdge>&)");
    dfs_params<TEdge> params;
    psetter(params);
    vector<int> component(g.adj.size());
    function<void(int, int)> dfs = [&](int u, int c) {
        component[u] = c;
        params.pre_node(u);
        for(int e : g[u]) if(not component[g(e).v]) {
            params.pre_edge(g(e)), dfs(g(e).v, c), params.pos_edge(g(e));
        }
        params.pos_node(u);
    };
    if(params.root) {
        dfs(params.root, 1);
    } else {
        for(int u = Index, c = 0; u < g.adj.size(); u++) if(not component[u]) {
            dfs(u, ++c);
        }
    }
    return component;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    graph<0, edge, 1> g(n, n - 1);
    for(int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g.add_edge({u, v});
    }
    string c;
    cin >> c;
    c.insert(c.begin(), ' ');
    vector<int> n_all_black_subtrees(n + 1), pchildren(n + 1);
    vector<ll> pr(n + 1);
    vector<multiset<ll>> ps(n + 1, multiset<ll>({0}));
    auto all_black = [&](int v) {
        return n_all_black_subtrees[v] == g[v].size() - 1 and c[v] == 'B';
    };
    auto flip_cost = [&](int u) {
        return (c[u] == 'W') ^ pchildren[u];
    };
    auto compute_ps = [&](int v) {
        return -(flip_cost(v) ^ 1) - 1 + *ps[v].begin() + (flip_cost(v) ^ not *ps[v].begin());
    };
    auto add_child = [&](int u, int v) {
        n_all_black_subtrees[u] += all_black(v);
        if(not all_black(v)) {
            pr[u] += (flip_cost(v) ^ 1) + pr[v] + 2;
            ps[u].insert(compute_ps(v));
            pchildren[u] ^= 1;
        }
    };
    auto remove_child = [&](int u, int v) {
        n_all_black_subtrees[u] -= all_black(v);
        if(not all_black(v)) {
            pr[u] -= (flip_cost(v) ^ 1) + pr[v] + 2;
            ps[u].erase(ps[u].find(compute_ps(v)));
            pchildren[u] ^= 1;
        }
    };
    dfs(g, [&](auto& p) {
        p.pos_edge = [&](edge& e) {
            add_child(e.u, e.v);
        };
    });
    ll ans = lim<ll>::max();
    dfs(g, [&](auto& p) {
        p.pre_edge = [&](edge& e) {
            remove_child(e.u, e.v);
            add_child(e.v, e.u);
        };
        p.pos_node = [&](int u) {
            ans = min(ans, (flip_cost(u) ^ bool(*ps[u].begin())) + pr[u] + *ps[u].begin());
        };
        p.pos_edge = [&](edge& e) {
            remove_child(e.v, e.u);
            add_child(e.u, e.v);
        };
    });
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 30416