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

// #undef DEBUG
// #define DEBUG
/// {{{ DEBUG --- ///
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { if(&o == &cerr) { o << '{'; for(size_t i = 0; i < v.size(); i++) o << v[i] << (i + 1 != v.size() ? ", " : ""); o << "}"; } else { for(size_t i = 0; i < v.size(); i++) o << v[i] << (i + 1 != v.size() ? " " : ""); } return o; }
#ifdef DEBUG
#define dump(...) (cerr<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<make_tuple(__VA_ARGS__)<<"\n")
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream &o, tuple<T...> const &t){ o << "("; _ot<0>(o, t); o << ")"; return o; }
#else
#define dump(...) (0)
#endif
/// }}}--- ///

const int N = 1e5;
vector<int> g[N];
string col;

bool allB[N];

// 根付き木で考える
// 根はW

// [頂点iから][iははじめBか][iへもどるか]
ll dp[N][2][2];
ll dp0[N][2];
ll dp2[N][2][2];
ll ans[N][2][2];
ll b[N];

// 非想定なはずの全方位木DP
// デバッグがつらいなどがある

template <class T, class U> inline void smax(T &a, U b) { a = a > b ? a : b; }
template <class T, class U> inline void smin(T &a, U b) { a = a < b ? a : b; }

bool dfs0(int i, int p) {
  allB[i] = col[i] == 'B';
  for(int j : g[i]) if(j != p) {
    allB[i] &= dfs0(j, i);
  }
  return allB[i];
}

void dfs(int i, int p) {
  ll a = 0;
  int cnt = 0;
  for(int j : g[i]) if(j != p) {
    if(allB[j]) continue;
    cnt++;
    dfs(j, i);
    ll d = 2 + dp[j][col[j] != 'B'][1];
    a += d;
    b[i] = min(b[i], -d + 1 + dp[j][col[j] != 'B'][0]);
  }
  int odd = cnt & 1;
  for(int B = 0; B < 2; B++) {
    dp0[i][B] = a;
    dp[i][B][1] = a + (1 ^ B ^ odd);
    // cnt == 0
    dp[i][B][0] = cnt == 0 ? dp[i][B][1] : a + b[i] + (B ^ odd);
  }
}

void dfs2(int i, int p) {
  for(int B = 0; B < 2; B++) {
    if(p != -1) {
      ll d = 2 + dp2[i][col[p] != 'B'][1];
      ans[i][B][1] = dp0[i][B] + d;
      b[i] = min(b[i], -d + 1 + dp2[i][col[p] != 'B'][0]);
      ans[i][B][0] = dp0[i][B] + d;
    } else {
      ans[i][B][1] = dp0[i][B];
      ans[i][B][0] = dp0[i][B];
    }
  }
  vector<ll> le(g[i].size(), 1e18);
  vector<ll> ri(g[i].size(), 1e18);
  int cnt = 0;
  for(int j : g[i]) {
    if(j == p) {
      le[cnt] = ri[cnt] =
        -(2 + dp2[i][col[p] != 'B'][1]) + 1 + dp2[i][col[p] != 'B'][0];
      cnt++;
      continue;
    }
    if(allB[j]) continue;
    le[cnt] = ri[cnt] = -(2 + dp[j][col[j] != 'B'][1]) + 1 + dp[j][col[j] != 'B'][0];
    cnt++;
  }
  int odd = cnt & 1;
  for(int x = 1; x < cnt; x++) {
    le[x] = min(le[x], le[x - 1]);
  }
  for(int x = cnt - 2; x >= 0; x--) {
    ri[x] = min(ri[x], ri[x + 1]);
  }
  {
    int x = 0;
    for(int j : g[i]) {
      if(allB[j]) continue;
      ll lle = x ? le[x - 1] : 0;
      ll rri = x < cnt - 1 ? ri[x + 1] : 0;
      ll mi = min(lle, rri);
      ll sbt = j == p ? 2 + dp2[i][col[p] != 'B'][1] : 2 + dp[j][col[j] != 'B'][1];
      for(int B = 0; B < 2; B++) {
        dp2[j][B][1] = ans[i][B][1] - sbt + (1 ^ 1 ^ B ^ odd);
        dp2[j][B][0] = cnt - 1 == 0 ? dp2[j][B][1] : ans[i][B][1] - sbt + mi + (1 ^ B ^ odd);
      }
      if(j != p) dfs2(j, i);
      x++;
    }
  }
  for(int B = 0; B < 2; B++) {
    ans[i][B][1] += (1 ^ B ^ odd);
    ans[i][B][0] += b[i] + (B ^ odd);
    if(cnt == 0) ans[i][B][0] = ans[i][B][1];
  }
}

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  for(int i = 0; i < n - 1; i++) {
    int a, b; cin >> a >> b; a--; b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  cin >> col;
  int p = -1;
  for(int i = 0; i < n; i++) if(col[i] != 'B') p = i;
  if(p == -1) {
    cout << 0 << endl;
    return 0;
  }
  dfs0(p, -1);
  dfs(p, -1);
  dfs2(p, -1);
  ll res = 1e18;
  for(int i = 0; i < n; i++) for(int j = 0; j < 2; j++) if(!allB[i]) {
    // dump(i, j, ans[i][col[i] == 'B'][j]);
    // dump(i, j, ans[i][col[i] != 'B'][j] + 1);
    smin(res, ans[i][col[i] == 'B'][j]);
    smin(res, ans[i][col[i] != 'B'][j] + 1);
    // dump(b[i]);
  }
  cout << res << endl;
}



Measured memory_bytes: 39504