#include <bits/stdc++.h>
using namespace std;

int N;
#define MAX_N 100000
vector<int> A[MAX_N]; string C;
set<int> V; vector<int> B[MAX_N]; bool J[MAX_N];
int R;

bool see(int v, int par) {
  bool res = C[v] == 'W';
  for(int w : A[v]) {
    if(w == par) continue;
    bool res_w = see(w, v);
    res = res || res_w;
  }
  if(res) V.insert(v);
  return res;
}
pair<int, int> farthest(int v, int par) {
  pair<int, int> res = {-1, 0};
  for(int w : B[v]) {
    if(w == par) continue;
    res = max(res, farthest(w, v));
  }
  if(res.first < 0) res = {0, v};
  if(!J[v]) ++res.first;
  return res;
}

int main() {
  cin >> N;
  for(int i = 0; i < N - 1; ++i) {
    int x, y; cin >> x >> y; --x; --y; A[x].push_back(y); A[y].push_back(x);
  }
  cin >> C;
  int v;
  for(v = 0; v < N; ++v) {
    if(C[v] == 'W') { see(v, -1); break; }
  }
  if(v == N) { cout << 0 << endl; return 0; }
  for(int v : V) {
    for(int w : A[v]) {
      if(!V.count(w)) continue;
      B[v].push_back(w);
    }
  }
  if(V.size() == 1) { cout << 1 << endl; return 0; }
  for(int v : V) {
    J[v] = ((int)B[v].size() % 2 == 0) == (C[v] == 'B');
    if(!J[v]) ++R;
  }
  auto res1 = farthest(*(V.begin()), -1);
  auto res2 = farthest(res1.second, -1);
  cout << R + 2 * ((int)V.size() - 1) - 2 * res2.first << endl;
  return 0;
}
