/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(__,v.size()){rep(_,v[__].size())cout<<" "<<v[__][_];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{
	int to,cost;
};
class DIA{//diameter of tree
	public:
	vector<vector<edge> >G;
	vi d;
	vector<bool>vis;
	int n;
	string S;
	DIA(int size){
		n=size;
		G=vector<vector<edge> >(n);
		d=vi(n);
		vector<bool>vis(n);
	}
	void add_edge(int a,int b,int c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);G[b].pb(ee);
	}
	void bfs(int s){
		d=vi(n,inf);
		queue<int>q;
		q.push(s);
		d[s]=0;
		int u;
		while(!q.empty()){
			u=q.front();q.pop();
			rep(i,G[u].size()){
				edge e=G[u][i];
				if(d[e.to]==inf){
					d[e.to]=d[u]+(S[e.to]=='W');
					q.push(e.to);
				}
			}
		}
	}
	void dia(string w){
		rep(i,w.size()){
			if(G[i].size()%4){
				if(w[i]=='B')w[i]='W';
				else w[i]='B';
			}
		}
		int co=-2;
		rep(i,G.size())if(G[i].size())co+=2;
		rep(i,w.size())if(w[i]=='W')co++;
		S=w;
		rep(i,G.size())if(G[i].size()==2){
			bfs(i);
			break;
		}
		int maxv=0,tgt=0;
		rep(i,n)if(d[i]!=inf&&maxv<d[i]&&G[i].size()==2){
			maxv=d[i];
			tgt=i;
		}
		
		bfs(tgt);
		maxv=0;
		rep(i,n)if(d[i]!=inf)maxv=max(maxv,d[i]);
		cout<<co-2*maxv<<endl;
	}
};
signed main(){
	int n;
	cin>>n;
	vi co(n);
	vvi G(n);
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].pb(b);
		G[b].pb(a);
		co[a]++;co[b]++;
	}
	string s;
	cin>>s;
	int c=0;
	rep(i,s.size())if(s[i]=='W')c++;
	if(c<=1){
		cout<<c<<endl;
		return 0;
	}
	queue<int>que;
	vi used(n,1);
	rep(i,n)if(co[i]==1&&s[i]=='B')que.push(i);
	while(!que.empty()){
		int a=que.front();
		que.pop();
		used[a]=0;
		rep(i,G[a].size()){
			int to=G[a][i];
			if(used[to]==0)continue;
			co[to]--;
			if(co[to]==1&&s[to]=='B')que.push(to);
		}
	}
	
	DIA dia(n);
	rep(i,n)rep(j,G[i].size())if(used[i]&&used[G[i][j]])
		dia.add_edge(i,G[i][j],0);
	dia.dia(s);
}















Measured memory_bytes: 21120