// Original C++ solution (slower):
#include <bits/stdc++.h>

#define N 100005



using namespace std;



inline int input() {

	int x; char ch; while (!isdigit(ch = getchar()));

	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));

	return x;

}



template <class T> void chkmax(T &x, T y) { x = x > y ? x : y; }

template <class T> void chkmin(T &x, T y) { x = x < y ? x : y; }



int n;

int du[N], dp[N];

int val[N], res, cnt, tot;

bool c[N], del[N];

vector<int> G[N];

char s[N];



inline void AddEdge(int x, int y) {

	G[x].push_back(y), ++du[x];

	G[y].push_back(x), ++du[y];

}



void dfs(int u, int fa) {

	dp[u] = val[u];

	for (int v : G[u])

		if (v != fa && !del[v]) {

			dfs(v, u);

			chkmax(res, dp[u] + dp[v]);

			chkmax(dp[u], dp[v] + val[u]);

		}

}



int main() {

	n = input();

	for (int i = 1, u, v; i < n; ++i) {

		u = input(), v = input();

		AddEdge(u, v);

	}

	scanf("%s", s + 1);

	for (int i = 1; i <= n; ++i)

		c[i] = s[i] == 'B';

		

	queue<int> que;

	for (int i = 1; i <= n; ++i)

		if (c[i] && du[i] == 1) que.push(i);

	while (!que.empty()) {

		int u = que.front(); que.pop();

		del[u] = true, ++tot;

		for (int v : G[u])

			if ((--du[v]) == 1 && c[v]) que.push(v);

	}

	

	if (tot == n) return puts("0"), 0;



	for (int u = 1; u <= n; ++u) {

		if (del[u]) continue;

		if (c[u] ^ (du[u] & 1)) val[u] = 0;

		else val[u] = 2, ++cnt;

	}



	for (int i = 1; i <= n; ++i)

		if (!del[i]) {

			dfs(i, 0);

			break;

		}

	printf("%d\n", (n - tot) * 2 - 2 + cnt - res);

	return 0;

}

// Optimized solution to the same problem (faster):
# include <iostream>

# include <cstdio>

using namespace std;

const int N = 2e5 + 12;

const int inf = 0x3f3f3f3f;

int n,head[N],dt,du[N],bac[N],que[N],rt,a[N],tot,p;char str[N];bool w[N];

struct Edge{int to,nex;}edge[N << 1];

void Add(int u,int v){edge[++dt] = (Edge){v,head[u]};head[u] = dt;du[u]++;}

void Dfs(int u,int pre)

{

    if(str[u] == 'W')w[u] = true;

    for(int i = head[u];i;i = edge[i].nex)if(edge[i].to != pre)

    {

        Dfs(edge[i].to,u);

        if(!w[edge[i].to])du[u]--,du[edge[i].to]--;

        w[u] |= w[edge[i].to];

    }

    if(w[u])tot++;

}

void rebuild()

{

    for(int i = 1;i <= n;i++)if(str[i] == 'W')rt = i;

    Dfs(rt,-1);

    for(int i = 1;i <= n;i++)if(w[i])a[i] = (str[i] == 'B') ^ (du[i] & 1),p += !a[i];

}

int dp[N][2],f[N];

void dfs(int u,int pre)

{

    f[u] = (tot - 1) * 2 + p;

    dp[u][0] = a[u] ? -1 : 1;

    for(int i = head[u];i;i = edge[i].nex)if(edge[i].to != pre && w[edge[i].to])

    {

        dfs(edge[i].to,u);

        f[u] = min(f[u],f[edge[i].to]);

        f[u] = min(f[u],(tot - 1) * 2 + p - dp[u][0] - dp[edge[i].to][1] - 1);

        f[u] = min(f[u],(tot - 1) * 2 + p - dp[u][1] - dp[edge[i].to][0] - 1);

        dp[u][0] = max(dp[u][0],dp[edge[i].to][0] + 1 + (a[u] ? -1 : 1));

        dp[u][1] = max(dp[u][1],dp[edge[i].to][1] + 1 + (a[u] ? -1 : 1));

    }

}

int main()

{

    

    scanf("%d",&n);int x,y;

    for(int i = 1;i < n;i++)scanf("%d %d",&x,&y),Add(x,y),Add(y,x);

    scanf("%s",str + 1);rebuild();dfs(rt,-1);

    printf("%d\n",!tot ? tot : f[rt]);

}




// Fastest known solution for this problem: