#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+7;
set< int >edg[MAXN];
int destroyed[MAXN];
int n;

char c[MAXN];

vector< int >child[MAXN];
int needsToggle[MAXN];

void dfs0(int u, int p) {
//    cout << u << " -> " << c[u] << endl;
    for (int v : edg[u]) {
        if (v==p||destroyed[v]) continue;
//        cout << u << " " << v << endl;
        child[u].push_back(v);
        dfs0(v, u);
    }
}

int m;
int totalW;

int add[MAXN];
int niche[MAXN];

int ans;
void dfs1(int u) {
    add[u] += needsToggle[u] ? -1 : 1;
//    cout << "add[" << u << "] = " << add[u] << endl;


    vector< int >vv;
    niche[u] = add[u];
    for (int v : child[u]) {
        add[v] = add[u] - 1;
        dfs1(v);
        niche[u] = min(niche[u], niche[v]);
        vv.push_back(niche[v]);
    }

//    cout << "niche[" << u << "] = " << niche[u] << endl;

    sort(vv.begin(), vv.end());
    if (vv.size() >= 2) {
//        cout << vv[0] << " , " << vv[1] << endl;
        int x = vv[0]-add[u] + vv[1]-add[u] + (needsToggle[u]?-1:1);
//        cout << u << " => " << x << endl;
        ans = min(ans, x);
    }
}

typedef pair< int , int >PII;

PII distant(int u, int from, int level) {
    if (needsToggle[u]) level++;
    else level--;
    PII p(level, u);

    for (int v : edg[u]) {
        if (v==from) continue;
        p = max(p, distant(v, u, level+1));
    }

    return p;
}

int main() {
    cin >> n;


    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        edg[u].insert(v);
        edg[v].insert(u);
    }

    cin >> (c+1);

//    if (n == 1) {
//        cout << (c[1]=='W') << endl;
//        return 0;
//    }

    {
        queue< int >q;
        for (int i = 1; i <= n; i++) {
            if (c[i]=='B' && edg[i].size() == 1) q.push(i);
        }

        m = n;
        while (!q.empty() && m > 1) {
            int u = q.front(); q.pop();
            destroyed[u] = true;
            m--;

            assert(edg[u].size() == 1);
            int v = *edg[u].begin();
            edg[v].erase(u);
            if (c[v] == 'B' && edg[v].size() == 1) q.push(v);
        }
    }

    if (m < 3) {
        ans = 0;
        for (int i = 1; i <= n; i++) ans += !destroyed[i] && c[i]=='W';
        cout << ans << endl;

//        cout << m << endl;
        return 0;
    }

    int root = 0;
    for (int i = 1; i <= n; i++) {
        if (!destroyed[i] && edg[i].size() > 1) {
            root = i;
        }
    }

    assert(root > 0);

    for (int i = 1; i <= n; i++) {
        if (!destroyed[i]) {
            int cur = c[i] == 'B';
            cur ^= edg[i].size() & 1;
            if (cur == 0) {
                needsToggle[i] = 1;
                totalW++;
//                cout << i << " needs toggle" << endl;
            }
        }
    }

    PII p = distant(root, 0, 0);
    PII q = distant(p.second, 0, 0);
    cout << 2*(m-1)+totalW-q.first-1 << endl;

//    cout << "total toggle " << totalW << endl;
//    cout << "edge total: " << 2*(m-1) << endl;

//    dfs0(root, 0);
//    cout << "root: " << root << endl;
//    ans = 0;
//    dfs1(root);
//
//    ans += 2*(m-1)+totalW;
//
//    cout << ans-1 << endl;


    return 0;
}


Measured memory_bytes: 28312