#include <bits/stdc++.h>

#define reg register
#define pr std::pair<int, int>
#define fi first
#define se second
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define lep(i, l, r) for (int i = l; i < r; ++i)
#define irep(i, r, l) for (int i = r; i >= l; --i)
#define ilep(i, r, l) for (int i = r; i > l; --i)
#define Rep(i, n) rep(i, 1, n)
#define Lep(i, n) lep(i, 1, n)
#define IRep(i, n) irep(i, n, 1)
#define ILep(i, n) ilep(i, n, 1)
typedef long long ll;
typedef long double ld;

namespace modular {
    const int MOD = 1000000007;
    inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }
    inline void inc(int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }
    inline int mul(int x, int y) { return 1LL * x * y % MOD; }
    inline int qpow(int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x))
            if (y & 1)
                ans = mul(ans, x);
        return ans;
    }
}; // namespace modular

namespace Base {
    template <typename Tp> inline Tp input() {
        Tp x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-')
                y = -1;
            c = getchar();
        }
        if (c == EOF)
            return 0;
        while ('0' <= c && c <= '9')
            x = x * 10 + c - '0', c = getchar();
        return x *= y;
    }
    template <typename Tp> inline void read(Tp &x) { x = input<Tp>(); }
    template <typename Tp> inline void chmax(Tp &x, Tp y) { x < y ? x = y : 0; }
    template <typename Tp> inline void chmin(Tp &x, Tp y) { x > y ? x = y : 0; }
}; // namespace Base
using namespace Base;
/*----------------------------------------------------------------------------*/

#define MAX_N 200007

int N;
int head[MAX_N], to[MAX_N << 1], nxt[MAX_N << 1], cap;
int sz[MAX_N], s2[MAX_N], deg[MAX_N], col[MAX_N], f[MAX_N];
int res;
char s[MAX_N];

void addE(int u, int v) {
    nxt[++cap] = head[u];
    head[u] = cap;
    to[cap] = v;
}

void dfs(int x, int las) {
    sz[x] = 1, s2[x] = col[x];
    for (int i = head[x]; i; i = nxt[i])
        if (to[i] != las) {
            dfs(to[i], x);
            sz[x] += sz[to[i]];
            s2[x] += s2[to[i]];
        }
    if (s2[x] == sz[x]) deg[las]--;
}

void dfs2(int x, int las) {
    int t1 = 0, t2 = 0;
    for (int i = head[x]; i; i = nxt[i])
        if (to[i] != las && sz[to[i]] != s2[to[i]]) {
            dfs2(to[i], x);
            if (f[to[i]] > t1) t2 = t1, t1 = f[to[i]];
            else chmax(t2, f[to[i]]);
        }
    int c = (deg[x] & 1) == col[x] ? 2 : 0;
    chmax(res, t1 + t2 + c);
    chmax(res, f[x] = t1 + c);
}

void solve() {
    int rt = -1;
    Rep(i, N) if (!col[i]) rt = i;
    if (rt == -1) return puts("0"), void();
    dfs(rt, 0);
    dfs2(rt, 0);
    int sum = 0;
    Rep(i, N) if (sz[i] != s2[i]) sum += deg[i] + ((deg[i] & 1) == col[i]);
    Rep(i, N) if (sz[i] != s2[i] && !deg[i]) return printf("%d\n", sum), void();
    printf("%d\n", sum - res);
}

int main() {
    read(N);
    int u, v;
    Lep(i, N) {
        read(u), read(v);
        addE(u, v), addE(v, u);
        deg[u]++, deg[v]++;
    }
    scanf("%s", s + 1);
    Rep(i, N) {
        col[i] = (s[i] == 'B');
    }
    solve();
    return 0;
}


Measured memory_bytes: 12416