#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
vi G[MAX_N];
int cnt[MAX_N], C[MAX_N];
int maxv = -1;

int loop(int v, int p) {
	vi dp;
	rep(i, 0, sz(G[v])) {
		int n = G[v][i];
		if(n == p) continue;
		dp.pb(loop(n, v));
	}
	sort(all(dp));
	if(sz(dp) == 0) return C[v] == 0;
	else if(sz(dp) == 1) {
		MAX(maxv, dp[0] + (C[v] == 0));
		return dp[0] + (C[v] == 0);
	}
	else {
		int at = sz(dp);
		MAX(maxv, dp[at - 1] + dp[at - 2] + (C[v] == 0));
		return dp[at - 1] + (C[v] == 0);
	}
}

void solve() {
	cin >> N;
	rep(i, 0, N - 1) {
		int a, b;
		cin >> a >> b; a--; b--;
		G[a].pb(b);
		G[b].pb(a);
		cnt[a]++; cnt[b]++;
	}
	string str;
	cin >> str;
	rep(i, 0, N) C[i] = (str[i] == 'B');
	if(accumulate(C, C + N, 0) == N) {
		cout << 0 << "\n"; return;
	}
	else if(accumulate(C, C + N, 0) == N - 1) {
		cout << 1 << "\n"; return;
	}
	queue<int> que;
	rep(i, 0, N) {
		if(C[i] == 1 && cnt[i] == 1) que.push(i);
	}
	while(!que.empty()) {
		int v = que.front(); que.pop();
		rep(i, 0, sz(G[v])) {
			int n = G[v][i];
			if(cnt[n] == 0) continue;
			cnt[v]--;
			cnt[n]--;
			if(cnt[n] == 1 && C[n] == 1) que.push(n);
		}
	}
	int root = -1;
	// debug(vi(cnt, cnt + N));
	rep(i, 0, N) {
		if(cnt[i] != 0) root = i;
	}
	int res = 0;
	int m = 0;
	rep(v, 0, N) {
		if(cnt[v] == 0) continue;
		m++;
		rep(i, 0, sz(G[v])) {
			int n = G[v][i];
			if(cnt[n] == 0) continue;
			C[v]++;
		}
		C[v] %= 2;
		res += 1 - C[v];
	}
	// debug(vi(C, C + N));
	res += 2 * (m - 1);
	loop(root, -1);
	// debug(res, m);
	res -= maxv * 2;
	// debug(maxv, m);
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 23504