#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<vector<int> > data;
int win, INF = -1e9;
vector<bool> used;
pair<int, int> dfs(int vertex, vector<bool> &v){
    used[vertex] = true;
    if (data[vertex].size() == 1){
        int cst = 1 + (!v[vertex]) - (v[vertex]);
        win = max(win, cst);
        return make_pair(cst, INF);
    }
    int maxl = INF, maxl2 = INF, maxr = INF, maxr2 = INF;
    int A = -1, B = -1;
    for (int i=0; i < data[vertex].size(); i++){
        int to = data[vertex][i];
        if (used[to]) continue;
        pair<int, int> p = dfs(to, v);
        int L = p.first, R = p.second;
        if (L > maxl){
            A = i;
            maxl2 = maxl;
            maxl = L;
        }
        else if (L > maxl2) maxl2 = L;
        if (R > maxr){
            B = i;
            maxr2 = maxr;
            maxr = R;
        }
        else if (R > maxr2) maxr2 = R;
    }
    int cst = 1 + (!v[vertex]) - (v[vertex]);
    win = max(win, cst);
    if (A != B) win = max(win, maxl + maxr + cst);
    else{
        win = max(win, maxl2 + maxr + cst);
        win = max(win, maxr2 + maxl + cst);
    }
    maxl += cst;
    maxr += cst;
    maxr = max(maxr, cst);
    return make_pair(maxl, maxr);

}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i=0; i < n; i++){
        vector<int> help;
        data.push_back(help);
    }
    for (int i=0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        data[a-1].push_back(b-1);
        data[b-1].push_back(a-1);
    }
    vector<bool> good;
    for (int i=0; i < n; i++){
        char ch;
        cin >> ch;
        if (ch == 'W') good.push_back(false);
        else good.push_back(true);
    }
    vector<int> f;
    for (int i=0; i < n; i++) f.push_back(data[i].size());
    vector<bool> rem(n);
    fill(rem.begin(), rem.end(), true);
    queue<int> q;
    for (int i=0; i < n; i++) if (f[i] <= 1 && good[i]) q.push(i);
    while (q.size()){
        int V = q.front();
        q.pop();
        rem[V] = false;
        for (int i=0; i < data[V].size(); i++){
            int to = data[V][i];
            f[to]--;
            if (f[to] == 1 && good[to]) q.push(to);
        }
    }
    map<int, int> num;
    int cur = 0;
    for (int i=0; i < n; i++){
        if (!rem[i]) continue;
        num[i] = cur;
        cur++;
    }
    vector<vector<int> > ndata;
    for (int i=0; i < n; i++){
        if (!rem[i]) continue;
        vector<int> ss;
        for (int j=0; j < data[i].size(); j++){
            int to = data[i][j];
            if (!rem[to]) continue;
            ss.push_back(num[to]);
        }
        ndata.push_back(ss);
    }
    data=ndata;
    vector<bool> ngood;
    for (int i=0; i < n; i++){
        if (!rem[i]) continue;
        ngood.push_back(good[i]);
    }
    good = ngood;
    if (data.size() == 0){
        cout << 0;
        return 0;
    }
    if (data.size() == 1){
        cout << 1;
        return 0;
    }
    if (data.size() == 2){
        cout << 2;
        return 0;
    }
    int ft = -1;
    for (int i=0; i < data.size(); i++) if (data[i].size() > 1) ft = i;
    for (int i=0; i < data.size(); i++) used.push_back(false);
    for (int i=0; i < data.size(); i++) if (data[i].size() % 2) good[i] = good[i] ^ 1;
    int pay = 2*data.size()-2;
    for (int i=0; i < data.size(); i++) if (!good[i]) pay++;
    win = 0;
    dfs(ft, good);
    cout << pay - win;
}


Measured memory_bytes: 29552