#include <bits/stdc++.h>

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 100010;

int n;
int head[MAXN], data[MAXN << 1], nxt[MAXN << 1], cnt;

int num[MAXN], sz[MAXN], all;

char cur[MAXN], down[MAXN], up[MAXN], can[MAXN];

void add(int x, int y)
{
	nxt[cnt] = head[x]; data[cnt] = y; head[x] = cnt++;
	nxt[cnt] = head[y]; data[cnt] = x; head[y] = cnt++;
}

void dfs(int now, int pa)
{
	sz[now] = 1;
	if (cur[now] == 'B') num[now]++;
	for (int i = head[now]; i != -1; i = nxt[i])
		if (data[i] != pa) dfs(data[i], now), num[now] += num[data[i]], sz[now] += sz[data[i]];
}

void dfs2(int now, int pa)
{
	if (num[now] == sz[now]) down[now] = true;
	if (all - num[now] == n - sz[now]) up[pa] = true;
	for (int i = head[now]; i != -1; i = nxt[i]) if (data[i] != pa) dfs2(data[i], now);
}

void dfs3(int now, int pa)
{
	int flag = -1;
	
	for (int i = head[now]; i != -1; i = nxt[i])
		if (data[i] != pa) {
			dfs3(data[i], now), up[now] |= up[data[i]];
			if (up[data[i]]) {
				if (flag != -1) flag = 0;
				else flag = data[i];
			}
		}
	
	if (flag != -1) {
		for (int i = head[now]; i != -1; i = nxt[i])
			if (data[i] != pa && data[i] != flag)
				down[data[i]] = true;
	}

	if (up[now]) can[now] = true;
}

void dfs4(int now, int pa)
{
	if (down[now]) can[now] = true;
	for (int i = head[now]; i != -1; i = nxt[i]) {
		if (data[i] == pa) continue;
		down[data[i]] |= down[now]; dfs4(data[i], now);
	}
}

int P, L, du[MAXN], nd[MAXN], dis[MAXN];

void dfs5(int now, int pa)
{
	dis[now] = dis[pa] + nd[now];
	for (int i = head[now]; i != -1; i = nxt[i]) if (data[i] != pa && !can[data[i]]) dfs5(data[i], now);
}

int main()
{
	in(n);
	
	memset(head, -1, sizeof head);
	FOR(i, 1, n - 1) {int x, y; in(x); in(y); add(x, y);}

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

	dfs(1, 0); all = num[1];
	dfs2(1, 0); dfs3(1, 0); dfs4(1, 0);

	FOR(i, 1, n) if (!can[i])
		for (int j = head[i]; j != -1; j = nxt[j])
			if (!can[data[j]]) du[i]++;

	FOR(i, 1, n) if (!can[i]) {
		P++;
		if ((du[i] & 1) ^ (cur[i] == 'W')) nd[i] = 1, L++;
	}

	FOR(i, 1, n) if (!can[i]) {
		if (P == 1 && cur[i] == 'W') {puts("1"); return 0;}
		dfs5(i, 0); break;
	}

	int mx = 0, mx2 = 0;
	FOR(i, 1, n) if (!can[i] && dis[i] >= dis[mx]) mx = i;

	if (!mx) {puts("0"); return 0;}

	dfs5(mx, 0);
	FOR(i, 1, n) if (!can[i] && dis[i] >= dis[mx2]) mx2 = i;

	printf("%d\n", 2 * (P - 1) + L - 2 * dis[mx2]);

	return 0;
}


Measured memory_bytes: 9984