#ifndef UTIL_INCLUDED
#define UTIL_INCLUDED

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
// #define DEBUGGING

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(0);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifndef DEBUG_FILE
#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#endif
#endif

#endif

using TLL = tuple<ll, ll, ll>;

VV<TLL> recv;
string color;
VV<ll> edges;
const ll INF = 5e15;

ll calc_save(const TLL &t) {
    ll a, b, i;
    tie(i, a, b) = t;
    return a - b;
}

void calc_change_here(ll now, PLL &cost, bool plus, PLL sp = PLL(-1, -1)) {
    ll s1, s2;
    if(sp.first == -1) {
        s1 = recv[now].size() + 1;
        s2 = recv[now].size();
    } else {
        tie(s1, s2) = sp;
    }
    bool cntf = (s1 & 1);
    bool cnts = (s2 & 1);
    bool col = color[now] == 'W';
    auto judge = [](ll s, bool cnt, bool col) { return (cnt ^ col) || (s <= 0 && col); };
    if(judge(s1, cntf, col)) cost.first  += (plus ? 1 : -1);
    if(judge(s2, cnts, col)) cost.second += (plus ? 1 : -1);
}

PLL dfs(ll now, ll pre) {
    for(ll nxt : edges[now]) if(nxt != pre) {
        PLL tmp = dfs(nxt, now);
        ll a, b;
        tie(a, b) = tmp;
        if(!(a + b)) continue;
        recv[now].emplace_back(nxt, a, b);
    }
    
    PLL ret;
    if(recv[now].size() == 0) return PLL(2 * (color[now] == 'W'), color[now] == 'W');
    
    sort(ALL(recv[now]), 
         [&](const TLL &a, const TLL &b) { return calc_save(a) > calc_save(b); });
    
    for(const TLL &t : recv[now]) {
        ll tmp = get<1>(t);
        ret.first += tmp;
        ret.second += tmp;
    }
    ret.second -= calc_save(recv[now][0]);
    calc_change_here(now, ret, true);
    if(ret.first) ret.first += 2;
    if(ret.second) ret.second++;
    return ret;
}

void swap_color(ll now) {
    if(color[now] == 'B') color[now] = 'W';
    if(color[now] == 'W') color[now] = 'B';
}

ll dfs(ll now, ll pre, PLL pcost) {
    {
        ll a, b;
        tie(a, b) = pcost;
        if(a + b && a != INF) if(!(b == 0 && color[pre] == 'B')) recv[now].emplace_back(pre, a, b);
    }

    ll csize = recv[now].size();
   
    recv[now].emplace_back(INF, INF, INF);
    sort(ALL(recv[now]), 
         [&](const TLL &a, const TLL &b) { 
             ll ca = calc_save(a);
             ll cb = calc_save(b);
             return (ca != cb ? ca > cb : get<0>(a) < get<0>(b));
         });

    PLL cost;
    DEBUG(now);
    DEBUG(recv[now]);
    DEBUG(pcost);
    for(TLL r : recv[now]) {
        ll tmp = get<1>(r);
        if(tmp == INF) continue;
        cost.first += tmp;
        cost.second += tmp;
    }

    cost.second -= calc_save(recv[now][0]);
    DEBUG(cost);
    calc_change_here(now, cost, true, make_pair(csize, csize - 1));
    DEBUG(cost);
    // ll ret = min(cost.first, cost.second == 0 ? INF : cost.second);
    ll ret = min(cost.first, cost.second);
    calc_change_here(now, cost, false, make_pair(csize, csize - 1));
    calc_change_here(now, cost, true, make_pair(1 + (csize - 1), 1 + csize - 2));
    
    for(TLL &t : recv[now]) {
        ll nxt = get<0>(t);
        if(nxt == pre) continue;
        if(nxt == INF) continue;
        auto arg = cost;
        DEBUG(arg);
        
        ll tmp = get<1>(t);
        if(tmp == INF) tmp = 0;
        arg.first -= tmp;
        
        if(nxt != get<0>(recv[now][0])) {
            arg.second -= tmp;
        } else {
            arg.second -= get<2>(recv[now][0]);
            arg.second -= calc_save(recv[now][1]);
        }
        DEBUG(arg);
        if(arg.first  || color[now] == 'W') arg.first += 2;
        if(arg.second || color[now] == 'W') arg.second += 1;
        
        DEBUG(arg);
        chmin(ret, dfs(nxt, now, arg));
    }
    DEBUG(ret);
    return ret;
}

int main() {
    ll N;
    cin >> N;
    recv.resize(N + 1);
    edges.resize(N + 1);
    for(ll i = 1; i < N; i++) {
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        edges[x].push_back(y);
        edges[y].push_back(x);
    }
    cin >> color;
    dfs(0, INF);
    DEBUG(recv);
    cout << dfs(0, INF, PLL(INF, INF)) << endl;
    return 0;
}


Measured memory_bytes: 30288