#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const long long INF = 1e18;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
vector <int> a[MAXN], b[MAXN];
int n, d[MAXN]; char col[MAXN];
long long dp[MAXN][3], ans;
bool vis[MAXN];
void work(int pos, int fa) {
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (fa != a[pos][i] && !vis[a[pos][i]]) work(a[pos][i], pos);
	bool now = col[pos] == 'B';
	long long tans = 2;
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (fa != a[pos][i] && !vis[a[pos][i]]) {
			tans += dp[a[pos][i]][0];
			now ^= true;
		}
	dp[pos][0] = tans + now;
	dp[pos][1] = tans + now - 1;
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (fa != a[pos][i] && !vis[a[pos][i]]) {
			chkmin(dp[pos][1], tans + !now - 1 - dp[a[pos][i]][0] + dp[a[pos][i]][1]);
		}
}
void getans(int pos, int fa) {
	if (fa == 0) {
		bool now = col[pos] == 'W'; int cnt = 0;
		long long tans = 0;
		for (unsigned i = 0; i < a[pos].size(); i++)
			if (fa != a[pos][i] && !vis[a[pos][i]]) {
				tans += dp[a[pos][i]][0];
				now ^= true;
				cnt++;
			}
		for (unsigned i = 0; i < a[pos].size(); i++)
			if (fa != a[pos][i] && !vis[a[pos][i]]) {
				dp[a[pos][i]][2] = dp[pos][0] - dp[a[pos][i]][0] - !now + now;
				getans(a[pos][i], pos);
			}
		if (cnt == 1) {
			for (unsigned i = 0; i < a[pos].size(); i++)
			if (fa != a[pos][i] && !vis[a[pos][i]]) {
				chkmin(ans, dp[a[pos][i]][1] + 1);
				return;
			}
		}
		chkmin(ans, tans + now);
		long long Max = -1e18, Nax = -1e18;
		for (unsigned i = 0; i < a[pos].size(); i++)
			if (fa != a[pos][i] && !vis[a[pos][i]]) {
				long long tmp = dp[a[pos][i]][0] - dp[a[pos][i]][1];
				if (tmp > Max) {
					Nax = Max;
					Max = tmp;
				} else chkmax(Nax, tmp);
			}
		chkmin(ans, 1 + tans + !now - Max - Nax);
	} else {
		for (unsigned i = 0; i < a[pos].size(); i++)
			if (fa != a[pos][i] && !vis[a[pos][i]]) {
				dp[a[pos][i]][2] = dp[pos][0] - dp[a[pos][i]][0] + dp[pos][2];
				getans(a[pos][i], pos);
			}
		bool now = col[pos] == 'B';
		long long tans = dp[pos][2];
		for (unsigned i = 0; i < a[pos].size(); i++)
			if (fa != a[pos][i] && !vis[a[pos][i]]) {
				tans += dp[a[pos][i]][0];
				now ^= true;
			}
		chkmin(ans, tans + now);
		long long Max = -1e18, Nax = -1e18;
		for (unsigned i = 0; i < a[pos].size(); i++)
			if (fa != a[pos][i] && !vis[a[pos][i]]) {
				long long tmp = dp[a[pos][i]][0] - dp[a[pos][i]][1];
				if (tmp > Max) {
					Nax = Max;
					Max = tmp;
				} else chkmax(Nax, tmp);
			}
		chkmin(ans, 1 + tans + !now - Max - Nax);
	}
}
int main() {
	read(n);
	for (int i = 1; i <= n - 1; i++) {
		int x, y; read(x), read(y);
		d[x]++, d[y]++;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	scanf("%s", col + 1);
	static int q[MAXN];
	int l = 0, r = -1;
	for (int i = 1; i <= n; i++)
		if (d[i] <= 1) q[++r] = i;
	while (l <= r) {
		int tmp = q[l++];
		if (col[tmp] == 'B') {
			vis[tmp] = true;
			for (unsigned i = 0; i < a[tmp].size(); i++)
				if (--d[a[tmp][i]] == 1) q[++r] = a[tmp][i];
		}
	}
	for (int i = 1; i <= n; i++)
		if (!vis[i]) {
			work(i, 0);
			ans = INF;
			getans(i, 0);
			writeln(ans);
			return 0;
		}
	printf("0\n");
	return 0;
}

Measured memory_bytes: 20608