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

string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << ' ' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  vector<int> deg(n);
  for (int _ = n - 1; _--; ) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
    ++deg[u], ++deg[v];
  }
  string s;
  cin >> s;
  if (s == string(n, 'B')) {
    cout << "0\n";
    exit(0);
  }
  queue<int> que;
  for (int v = 0; v < n; ++v) {
    if (deg[v] == 1 and s[v] == 'B') {
      que.push(v);
    }
  }
  vector<bool> be(n, true);
  while (not que.empty()) {
    int v = que.front();
    que.pop();
    be[v] = false;
    for (int u : g[v]) {
      if (be[u]) {
        --deg[v];
        --deg[u];
        if (deg[u] == 1 and s[u] == 'B') {
          que.push(u);
        }
        break;
      }
    }
  }
  int res = 0;
  vector<int> a(n);
  for (int v = 0; v < n; ++v) {
    if (be[v]) {
      res += deg[v];
      if (s[v] == 'W') {
        if (deg[v] % 2 == 0) {
          a[v] = deg[v] ? 2 : 0;
          ++res;
        }
      } else {
        if (deg[v] & 1) {
          a[v] = 2;
          ++res;
        }
      }
    }
  }
  int r = find(begin(be), end(be), true) - begin(be);
  vector<vector<int>> dp(2, vector<int>(n));
  {
    auto dfs = [&](auto&& self, int v, int p) -> void {
      for (int u : g[v]) {
        if (be[u] and u != p) {
          self(self, u, v);
          if (a[u] + dp[0][u] > dp[0][v]) {
            dp[1][v] = dp[0][v];
            dp[0][v] = a[u] + dp[0][u];
          } else if (a[u] + dp[0][u] > dp[1][v]) {
            dp[1][v] = a[u] + dp[0][u];
          }
        }
      }
    };
    dfs(dfs, r, -1);
  }
  vector<int> rdp(n);
  {
    auto dfs = [&](auto&& self, int v, int p) -> void {
      multiset<int> ms;
      ms.insert(a[v] + rdp[v]);
      for (int u : g[v]) {
        if (be[u] and u != p) {
          ms.insert(a[v] + a[u] + dp[0][u]);
        }
      }
      for (int u : g[v]) {
        if (be[u] and u != p) {
          ms.erase(ms.find(a[v] + a[u] + dp[0][u]));
          rdp[u] = ms.empty() ? 0 : *rbegin(ms);
          ms.insert(a[v] + a[u] + dp[0][u]);
          self(self, u, v);
        }
      }
    };
    dfs(dfs, r, -1);
  }
  DEBUG(dp[0]);
  DEBUG(dp[1]);
  DEBUG(rdp);
  int mx = 0;
  for (int v = 0; v < n; ++v) {
    if (be[v]) {
      mx = max(mx, a[v] + dp[0][v] + dp[1][v] + rdp[v] - min({dp[0][v], dp[1][v], rdp[v]}));
    }
  }
  res -= mx;
  cout << res << '\n';
}


Measured memory_bytes: 27208