#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

class DiameterOfTree{
public:
  typedef pair<int,int> P;
  int V;
  vector<vector<P> > G;
  vector<int> nodeCost;
  int start, end, length;
  DiameterOfTree():V(-1){}
  DiameterOfTree(int V):V(V),G(V),nodeCost(V, 0){};
  
  void add_edge(int a,int b,int c = 1){
    assert(a < V && b < V);
    assert(a >= 0 && b >= 0);
    G[a].push_back(P(b,c));
    G[b].push_back(P(a,c));
  }
  
  P dfs(int pos,int pre = -1,int len = 0){
    len += nodeCost[pos];
    if(pre == -1) start = pos, length = -1;
    if(len > length) length = len, end = pos;
    for(P p:G[pos]) if(p.first != pre) dfs(p.first, pos, len+p.second);
    return P(end,length);
  }

  //O(N);
  void build(int start=0){assert(start < V);dfs(dfs(start).first);}
};

int n;
vector<vector<int> > G;
string col;
void mkG(){

  function<int(int,int)> dfs = [&](int pos,int pre){
    vector<int> tmp;
    for(int to:G[pos]) if(pre == to || dfs(to, pos) == 0) tmp.push_back(to);
    
    G[pos].clear();
    if((int)tmp.size() == 1 && col[pos] == 'B') return 1;
    G[pos] = tmp;
    return 0;
  };
  
  int root;
  for(root = 0; root < n && col[root] != 'W'; root++);
  dfs(root, root);
  
  int nn = 0;
  for(int i=0;i<n;i++) nn += !(G[i].empty() && col[i] == 'B');
  
  vector<vector<int> > nG(nn);
  string ncol;
  
  map<int,int> Idx;
  int cnt = 0;
  for(int i=0;i<n;i++){
    if(G[i].empty() && col[i] == 'B') continue;
    if(!Idx.count(i)) Idx[i] = cnt++, ncol += col[i];
    for(int to:G[i]){
      if(!Idx.count(to)) Idx[to] = cnt++, ncol += col[to];
      nG[Idx[i]].push_back(Idx[to]);
    }
  }
  assert(cnt == nn);
  n = nn;
  G = nG;
  col = ncol; 
}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  
  cin>>n;
  G.resize(n);
  for(int i=0;i<n-1;i++){
    int x, y;
    cin>> x >> y; x--, y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  cin>>col;
  
  if(count(col.begin(),col.end(), 'B') == n){
    cout<<0<<endl;
    return 0;
  }
 
  if(n == 1){
    int ans = col[0] == 'W';
    cout<<ans<<endl;
    return 0;
  }
  
  if(n == 2){
    int ans = count(col.begin(), col.end(), 'W');
    cout<<ans<<endl;
    return 0;
  }  
  
  mkG();
  if(n == 1) {cout<<1<<endl; return 0;}
  
  vector<int> BW(n);
  for(int i=0;i<n;i++) BW[i] = (col[i] == 'W') ^ (G[i].size()% 2);
  
  DiameterOfTree T(n);
  for(int i=0;i<n;i++)
    for(int to:G[i]) if(i < to) T.add_edge(i, to, 0);
  
  T.nodeCost = BW;
  T.build();
  
  
  int len = T.length;
  int ans = 2*(n-1) - 2 * len + count(BW.begin(),BW.end(), 1);
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 30160