#include<bits/stdc++.h>

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

typedef pair<int,int>   ii;

vector<int> g[N];

int vis[N];
int deg[N];

int f[N];
int c[N];

int ans = 0;

void dfs(int u,int p)   {
    int mx1 = 0;
    int mx2 = 0;

    for(int v : g[u])   if (v != p) {
        dfs(v,u);

        if (mx2 < f[v]) mx2 = f[v];
        if (mx1 < mx2)  swap(mx1,mx2);
    }
    f[u] = c[u] + mx1;

    if (ans < c[u] + mx1 + mx2)
        ans = c[u] + mx1 + mx2;
}

int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n;  cin >> n;

    for(int i = 1 ; i < n ; ++i)    {
        int x;  cin >> x;
        int y;  cin >> y;

        g[x].pb(y); deg[x]++;
        g[y].pb(x); deg[y]++;
    }
    string S;   cin >> S;   S = "#" + S;
    queue<int>  qu;

    for(int i = 1 ; i <= n ; ++i)
        if (deg[i] == 1 && S[i] == 'B')
            vis[i] = 1,
            qu.push(i);

    while (qu.size())   {
        int u = qu.front(); qu.pop();

        for(int v : g[u])   if(!vis[v]) {
            deg[v]--;
            if (deg[v] == 1 && S[v] == 'B') {
                vis[v] = 1;
                qu.push(v);
            }
        }
    }
    int R = 0;
    int s = -2;

    for(int i = 1 ; i <= n ; ++i)   if(!vis[i]) {
        c[i] = (S[i] == 'W') ^ (deg[i] & 1);
        R = i;
        s += 2 + c[i];

        vector<int> vec = g[i]; g[i].clear();

        for(int x : vec)    if(!vis[x])
            g[i].pb(x);
    }
    if (R == 0) return  cout << 0,0;
    else    {
        dfs(R,0);

        cout << abs(s - 2 * ans) << endl;
    }
}