#include <bits/stdc++.h>
using namespace std;

const int N = 100005;
int n, cost, ans, mxd[N], mxd2[N];
vector<int> g[N];
char s[N];

void dfs(int u, int fa) {
	int deg = 0;
	for (int v : g[u])
		if (v != fa) {
			dfs(v, u);
			if (s[v] != 1) ++deg;
		}
	if (!deg && s[u] == 'B') { s[u] = 1; return; }
	deg &= 1;
	if (fa) deg ^= 1;
	int val = 2 * (s[u] == 'W' ^ deg);
	cost += s[u] == 'W' ^ deg;
	if (fa) cost += 2;
	for (int v : g[u])
		if (s[v] != 1 && v != fa) {
			ans = max(ans, val + mxd[u] + mxd2[v]);
			ans = max(ans, mxd2[u] + mxd[v]);
			mxd[u] = max(mxd[u], mxd[v]);
			mxd2[u] = max(mxd2[u], val + mxd2[v]);
		}
	ans = max(ans, mxd[u]);
	mxd[u] += val;
	ans = max(ans, mxd2[u]);
}

int main() {
	scanf("%d", &n);
	for (int i = 1, x, y; i < n; ++i) {
		scanf("%d%d", &x, &y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	scanf("%s", s + 1);
	int rt = -1;
	for (int i = 1; i <= n; ++i)
		if (s[i] == 'W') rt = i;
	if (rt == -1) puts("0");
	else {
		dfs(rt, 0);
		printf("%d\n", cost - ans);
	}
	return 0;
}
