#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int N;
char c[100000];
int x[100000];
int y[100000];
int cnt[100000];
int state[100000];
int cnt_maxw[100000];
int w, b;
vector<int> G[100000];
vector<int> Gw[100000];
bool used[100000];
bool used_[100000];

void clear(){
    for(int i = 0; i < N; i++) used[i] = false;
}

void dfsb(int v){
    used[v] = true;
    // cnt[v]--;
    for(int i = 0; i < G[v].size(); i++){
        if(!used[G[v][i]]) {
            cnt[G[v][i]]--;
            if(cnt[G[v][i]] == 1 && c[G[v][i]] == 'B') dfsb(G[v][i]);
        }
    }
}

int max_path_w;

void dfsw(int v){
    used[v] = true;
    used_[v] = true;
    cnt_maxw[v] = state[v];
    int ch = 0;
    for(int i = 0; i < Gw[v].size(); i++){
        if(!used[Gw[v][i]]) {
            dfsw(Gw[v][i]);
            ch++;
            int tmp = state[v];
            cnt_maxw[v] = max(cnt_maxw[v], tmp+cnt_maxw[Gw[v][i]]);
        }
    }
    if(ch >= 2){
        vector<int> u;
        // おやはこのタイミングではどうせ0
        for(int i = 0; i < Gw[v].size(); i++){
            u.push_back(cnt_maxw[Gw[v][i]]);
        }
        sort(u.begin(), u.end(), greater<int>());
        int tmp = state[v];
        max_path_w = max(max_path_w, tmp+u[0]+u[1]);
    }else{
        max_path_w = max(max_path_w, cnt_maxw[v]);
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N-1; i++){
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
        cnt[x[i]]++;
        cnt[y[i]]++;
        G[x[i]].push_back(y[i]);
        G[y[i]].push_back(x[i]);
    }
    for(int i = 0; i < N; i++) {
        cin >> c[i];
        if(c[i] == 'W') w++;
        else b++;
    }
    for(int i = 0; i < N; i++) {
        if(!used[i] && c[i] == 'B' && cnt[i] == 1) dfsb(i);
    }
    // for(int i = 0; i < N; i++) {
    //     if(!used[i]) cout << i << ' ';
    // }
    // cout << endl;
    // for(int i = 0; i < N; i++) {
    //     if(!used[i]) cout << cnt[i] << ' ';
    // }
    // cout << endl;
    int cnt_path = 0;
    for(int i = 0; i < N-1; i++){
        if(!used[x[i]] && !used[y[i]]) {
            cnt_path++;
            Gw[x[i]].push_back(y[i]);
            Gw[y[i]].push_back(x[i]);
        }
    }
    for(int i = 0; i < N; i++) {
        int col = c[i] == 'W' ? 1:0;
        if(!used[i]) state[i] = col^(cnt[i]%2);
    }
    // for(int i = 0; i < N; i++) {
    //     if(!used[i]) cout << state[i] << ' ';
    // }
    // cout << endl;
    for(int i = 0; i < N; i++) {
        if(c[i] == 'W') {
            dfsw(i);
            break;
        }
    }
    int cntw = 0;
    int tmp = 0;
    for(int i = 0; i < N; i++) {
        if(state[i] == 1) {
            cntw++;
        }
    }
    if(w == 0) {
        cout << 0 << endl;
        return 0;
    }
    if(w == 1){
        cout << 1 << endl;
        return 0;
    }
    // for(int i = 0; i < N; i++) cout << state[i] << ' ';
    // cout << endl;
    // cout << cnt_path << ' ' << max_path_w << endl;
    cout << cnt_path*2+cntw-(2*max_path_w-1)-1 << endl;
}

Measured memory_bytes: 21248