#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (int)1e9//(long long) 1e18//1234567890987654321
#define INF 1234567890
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN 300006/3
#define MAXK 26
#define MAXX 15000006
#define ll /*long long*/ int
#define ld long double
#define rep0(kk, l1, l2)for(ll kk = l1; kk < l2; kk++)
#define rep1(kk, l1, l2)for(ll kk = l1; kk <= l2; kk++)
#define foritr(itr, A) for(set<ll>::iterator itr = A.begin(); itr != A.end(); itr++)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define cr(x) cerr << #x << " = " << x << "\n";
#define crA(x, A) cerr << #x << " = " << A[x] << "\n";
#define spacing cout << " ";
#define mmst(x, v) memset((x), v, sizeof ((x)));
#define bg(ms) (*ms.begin())
#define ed(ms) (*prev(ms.end(), 1))
#define addedge(a, b, c, v) v[(a)].pb(pi((b), (c))); v[(b)].pb(pi((a), (c)))
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivess
ll n, colour[MAXN], r, value[MAXN], dist[2][MAXN], depth[MAXN], par[MAXN];
vector <ll> v[MAXN];
queue <ll> q;
vector <ll> hmm;
void setleaves(ll x, ll p)
{
	// cout << x << " " << p << '\n';
	// if(x==6)for(auto i : v[x]) cout << i << ' '; cout << endl;
	vector <ll> tmp = v[x];
	for(auto i : tmp)
	{
		// if(x==6)cout << "^: " << i << "\n";
		if(i!=p){/*if(x==6)cout << "^: " << i << "\n";*/ setleaves(i, x);}
	}
	// if(x!=r)
	// {
		if(v[x].size() == 1 && colour[x] == 1)
		{
			for(auto i : v[x])
			{
				// assert(v[i].find(x)!=v[i].end() && i != x);
				assert(i==p);
				v[i].erase(find(all(v[i]), x));
			}
			v[x].clear();
				if(db)cout << "CBE " << x << '\n';
			// hmm.pb(x);
			//~ cout << x << " out\n";
		}
	// }
	return;
}
void dfs(ll x, ll p)
{
	par[x] = p;
	for(auto i : v[x])
	{
		if(i==p)continue;
		depth[i] = depth[x] + 1;
		dfs(i, x);
	}
	if(v[x].size() <= 1) { /*if(colour[x] == 1) { cout << p << colour[v[x][0]] << ' ' << x << ' ' << colour[x] << ' ' << r << ' ' << colour[r] << '\n'; }*/ assert(!colour[x]);  value[x] = 0; }
	else if(colour[x]== 0) value[x] = ((v[x].size()%2)==0 ? 1 : -1);
	else value[x] = ((v[x].size()%2)==0 ? -1 : 1);
}
ll totalpay = 0;
struct diam
{
	void dfs(ll x, ll p, ll alt)
	{
		for(auto i : v[x])
		{
			if(i==p)continue;
			//~ assert(value[i] != 0);
			dist[alt][i] = dist[alt][x] + value[i]+1+(value[i]==0);
			dfs(i, x, alt);
		}
	}	
	pi diameter(ll r)
	{
		for(ll i = 0; i <= n; i++)dist[0][i] = dist[1][i] = -LLINF;
		dist[0][r]=0;
		dfs(r, r, 0);
		ll e1 = r;
		for(ll i = 1; i <= n; i++)if(dist[0][e1] < dist[0][i])e1 = i;
		assert(dist[0][e1] != -LLINF);
		
		for(ll i = 0; i <= n; i++)dist[0][i] = dist[1][i] = -LLINF;
		dist[0][e1] = 0;
		dfs(e1, e1, 0);
		ll e2 = e1;
		for(ll i = 1; i <= n; i++) if(dist[0][e2] < dist[0][i]) e2= i;
		return pi(e1, e2);
	}
} diam;
ll no1 = 0, totaldists;
struct answer
{
	ll dist[MAXN]; ll road[MAXN];
	void init() {mmst(dist, 0);mmst(road, 0);}
	void solve(ll x, ll p, ll y, ll l)
	{
		if(x!=y)totalpay += (value[x]==1);
		/*no1 += (value[x]==1);
		no1 -= (value[x]==-1);*/
		for(auto i : v[x])
		{
			if(i==p)continue;
			road[i] = road[x];
			// if(i!=l){
				road[i] -= (value[i]==1);
				road[i] += (value[i]==-1);
					if(db)cerr << i << ": " << road[i] << ' ' << value[i] << ' ' << colour[i] << '\n';
			dist[i] = dist[x] + 1;
			totaldists++;
			solve(i, x, y, l);
		}
	}
} answer;
int main()
{
    FAST
// 	freopen("mcinput3.txt", "r", stdin);
	cin >> n; 
	for(ll i = 0; i < n-1; i++)
	{
		ll a, b;
		cin >> a >> b;
		v[a].pb(b);
		v[b].pb(a);
	}
	ll allblack = 1;
	for(ll i = 1; i <= n; i++) { char ch; cin >> ch; colour[i] = (ch == 'W' ? 0 : 1); if(ch == 'W') {allblack = 0; r=i;}}
	if(allblack) { cout << 0 <<"\n"; return 0; }
	//catch all black nodes
	setleaves(r, r); if(db)cout << "CBE\n";
	for(ll i = 1; i <= n; i++) if(!v[i].empty()&&colour[i]==0) { r = i; break; } 
	dfs(r, -1);
	pi x = diam.diameter(r);
	answer.init();
	// assert(value[x.f] != -1&&!colour[x.f]); 
	answer.road[x.f] += (!colour[x.f]);
	//~ answer.road[x.f] += (value[x.f]==-1);
	answer.solve(x.f, x.f, x.f, x.s);
	cout << (totalpay + (totaldists*2 - answer.dist[x.s])) + answer.road[x.s] << "\n";
	if(db)
	{
		cerr << x.f << ' ' << x.s << '\n';
		cerr << totalpay << ' ' << answer.road[x.s] << '\n';
	}
}

Measured memory_bytes: 19840