#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,x,y,i,s,u,md,f[N];
char c[N];
vector<int>e[N];
int dfs(int x,int fa){
	int ret=0,deg=fa>0;
	if(c[x]=='W')ret=1;
	for(int y:e[x])if(y!=fa && dfs(y,x))ret=1,s+=2,deg++;
	if(ret)s+=f[x]=(deg&1)!=(c[x]=='W'),f[x]=f[x]?2:0;else f[x]=-1;
	return ret;
}
void dfss(int x,int fa,int d){
	d+=f[x];if(d>=md)md=d,u=x;
	for(int y:e[x])if(y!=fa && f[y]!=-1)dfss(y,x,d);
}
int main(){
	scanf("%d",&n);
	for(i=1;i<n;++i)scanf("%d%d",&x,&y),e[x].push_back(y),e[y].push_back(x);
	scanf("%s",c+1);
	for(i=1;i<=n;++i)if(c[i]=='W')break;
	if(i>n){puts("0");return 0;}
	dfs(i,0);md=-N;dfss(i,0,0);md=-N;dfss(u,0,0);
	printf("%d\n",s>1?s-md:1);
	return 0;
}