#include<bits/stdc++.h>

using namespace std;

#define allof(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5 + 5;

int N;

vector<int> adj[MAXN];
int edges[MAXN];
char col[MAXN];
bool removed[MAXN];
int remain;

//if we travel each edge once in each direction, does this node need fixing?
int fixval(int x){
    return (edges[x] % 2 == 0 && col[x] == 'W') || (edges[x] % 2 == 1 && col[x] == 'B') ? 1 : -1;
}

int reduce = 0;

pii bestup[MAXN][3];
pii bestdown[MAXN][3];

void dfs(int pos, int par){
    bestup[pos][0] = pii(fixval(pos), pos);
    bestup[pos][1] = pii(-1e9, -1);
    bestup[pos][2] = pii(-1e9, -2);

    bestdown[pos][0] = pii(0, pos);
    bestdown[pos][1] = pii(-1e9, -1);
    bestdown[pos][2] = pii(-1e9, -2);

    for(int i : adj[pos]){
        if(i == par || removed[i]){
            continue;
        }
        dfs(i, pos);

        pii up = pii(bestup[i][0].first + 1 + fixval(pos), i);
        pii down = pii(bestdown[i][0].first + 1 + fixval(pos), i);

        //cout << pos << " from " << i << " get " << up.first << " and " << down.first << endl;

        if(up > bestup[pos][0]){
            bestup[pos][2] = bestup[pos][1];
            bestup[pos][1] = bestup[pos][0];
            bestup[pos][0] = up;
        } else if (up > bestup[pos][1]){
            bestup[pos][2] = bestup[pos][1];
            bestup[pos][1] = up;
        } else if (up > bestup[pos][2]){
            bestup[pos][2] = up;
        }

        if(down > bestdown[pos][0]){
            bestdown[pos][2] = bestdown[pos][1];
            bestdown[pos][1] = bestdown[pos][0];
            bestdown[pos][0] = down;
        } else if (down > bestdown[pos][1]){
            bestdown[pos][2] = bestdown[pos][1];
            bestdown[pos][1] = down;
        } else if (down > bestdown[pos][2]){
            bestdown[pos][2] = down;
        }
    }
    
    if(bestup[pos][0].second == pos){
        reduce = max(reduce, bestup[pos][1].first - fixval(pos));
    } else {
        reduce = max(reduce, bestup[pos][0].first - fixval(pos));
    }

    if(bestdown[pos][0].second == pos){
        reduce = max(reduce, bestdown[pos][1].first);
    } else {
        reduce = max(reduce, bestdown[pos][0].first);
    }

    for(int a = 0; a < 3; a++){
        for(int b = 0; b < 3; b++){
            if(bestup[pos][a].second == bestdown[pos][b].second){
                continue;
            }
            
            if(bestup[pos][a].second == pos){
                continue;
            }

            if(bestdown[pos][b].second == pos){
                continue;
            }

            reduce = max(reduce, bestup[pos][a].first + bestdown[pos][b].first - fixval(pos));
        }
    }

/*
    cout << pos << " has\n";
    for(int a = 0; a < 3; a++){
        cout << "[" << bestup[a].first << ", " << bestup[a].second << "]";
        cout << "[" << bestdown[a].first << ", " << bestdown[a].second << "]";
        cout << endl;
    }
    cout << endl;
*/
}

int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    cin >> N;
    
    remain = N;
    for(int a = 1; a <= N - 1; a++){
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);

        edges[u]++;
        edges[v]++;
    }

    cin >> (col + 1);

    if(N == 1){
        cout << (col[1] == 'W');
        return 0;
    }

    queue<int> q;
    for(int a = 1; a <= N; a++){
        if(edges[a] == 1 && col[a] == 'B'){
            q.push(a);
        }
    }

    while(!q.empty()){
        int fr = q.front();
        q.pop();

        remain--;
        removed[fr] = true;

        for(int i : adj[fr]){
            edges[i]--;
            if(edges[i] == 1 && col[i] == 'B'){
                q.push(i);
            }
        }
    }

    if(remain == 0){
        cout << 0;
        return 0;
    }

    int start = -1;
    for(int a = 1; a <= N; a++){
        if(!removed[a]){
            start = a;
            break;
        }
    }

    if(start == -1){
        cout << 0;
    } else if (remain == 1){
        cout << (col[start] == 'W');
    } else if (remain == 2){
        cout << 2;
    } else {
        int ans = 2 * (remain - 1);
        for(int a = 1; a <= N; a++){
            if(!removed[a] && fixval(a) == +1){
                ans++;
            }
        }

        dfs(start, -1);

        cout << ans - reduce;
    }
}


Measured memory_bytes: 17920