#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int>g[N];
int freq[N],bad,dp[N],ans = 1e9,n,sz[N];
bool col[N],vis[N];
queue<int>q;
string s;
void calc(int u,int p){
	vis[u] = 1;
	int at = (sz[u] + col[u])&1 ? 0 : -2,mn = 1e9,mn2 = 1e9;
	for(auto i : g[u])
		if(i != p && !vis[i]){
			calc(i,u);
			mn2 = min(mn2,dp[i]);
			if(mn2 < mn)swap(mn,mn2);
		}
	dp[u] = min(0,mn) + at;
	ans = min(ans,min(dp[u],mn + mn2 + at));
}
int main(){
	//freopen("readin.txt","r",stdin);
	scanf("%d",&n);
	for(int i = 1,a,b;i < n;i++)
		scanf("%d%d",&a,&b),
		g[--a].push_back(--b),
		g[b].push_back(a);
	cin >> s;
	int temp = 0;
	for(int i = 0;i < n;i++)col[i] = s[i] == 'B';
	for(int i = 0;i < n;i++)temp+=!col[i];
	if(!temp)return printf("%d\n",temp),0;
	for(int i = 0;i < n;i++)
		if(g[i].size() == 1 && col[i])q.push(i),vis[i] = 1;
	temp = 0;
	while(!q.empty()){
		int x = q.front();
		temp++;
		q.pop();
		for(auto i : g[x])
			if((++freq[i]) + 1 == g[i].size() && col[i])
				vis[i] = 1,
				q.push(i);
	}
	for(int i = 0;i < n;i++)
		for(auto j : g[i])sz[i]+=!vis[j];
	for(int i = 0;i < n;i++)
		if(!vis[i] && !((sz[i] + col[i])&1))bad++;
	for(int i = 0;i < n;i++)if(!vis[i] && !col[i])calc(i,-1);
	if (temp + 1 == n)printf("1\n");
	else printf("%d\n",2*(n - 1 - temp) + ans + bad);
}
