// ${url}
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}


#[derive(Debug, Clone, PartialEq)]
struct State {
    is_white: bool,
    children: usize,
    best: (i64, i64),
    value: Vec<i64> // value[0] = back, value[1] = go
}

fn add(now: usize, child: usize, states: &mut Vec<State>) {
    let back = states[child].value[2];
    let go = states[child].value[3];
    if back == -1 {
        return;
    }
    let back_dgo = back - go;
    let (mut one, mut two) = states[now].best;
    if one < back_dgo {
        two = one;
        one = back_dgo;
    } else if two < back_dgo {
        two = back_dgo;
    }
    states[now].children += 1;
    states[now].value[0] += back + 2;
    states[now].value[1] = states[now].value[0] - one - 1;
    let add = ifv!(((states[now].children + 1) % 2 == 1) ^ states[now].is_white, 1, 0);
    states[now].value[2] = states[now].value[0] + add;
    states[now].value[3] = states[now].value[1] + (add ^ 1);
    states[now].best = (one, two);
}

fn remove(now: usize, child: usize, states: &mut Vec<State>) {
    let back = states[child].value[2];
    let go = states[child].value[3];
    if back == -1 {

        return;
    }

    let back_dgo = back - go;
    let (one, two) = states[now].best;

    states[now].children -= 1;
    states[now].value[0] -= back + 2;
    states[now].value[1] = states[now].value[0] - ifv!(one == back_dgo, two, one) - 1;
    let add = ifv!(((states[now].children + 1) % 2 == 1) ^ states[now].is_white, 1, 0);
    states[now].value[2] = states[now].value[0] + add;
    states[now].value[3] = states[now].value[1] + (add ^ 1);
    states[now].best = ifv!(one == back_dgo, (two, 0), ifv!(two == back_dgo, (one, 0), (one, two)));

    if states[now].children == 0 {
        if states[now].is_white {
            states[now].value[0] = 0;
            states[now].value[1] = 0;
            states[now].value[2] = 0;
            states[now].value[3] = 0;
            states[now].best = (0, 0);
        } else {
            states[now].value[0] = 0;
            states[now].value[1] = 0;
            states[now].value[2] = -1;
            states[now].value[3] = -1;
            states[now].best = (0, 0);
        }
    }
}

fn dfs(now: usize, par: Option<usize>, graph: &Vec<Vec<usize>>, states: &mut Vec<State>) {
    for &to in &graph[now] {
        if Some(to) == par {
            continue;
        }
        dfs(to, Some(now), graph, states);
        add(now, to, states);
    }
}

fn dfs2(now: usize, par: Option<usize>, graph: &Vec<Vec<usize>>, states: &mut Vec<State>) -> i64 {
    let mut best = states[now].value[1];
    if states[now].children == 0 {
        best += ifv!(states[now].is_white, 1, 0);
    } else {
        let flip = (states[now].children - 1) % 2;
        best += ifv!(states[now].is_white ^ (flip == 1), 1, 0);
    }

    let ws = states[now].value.clone();

    // debug!(now, best);
    // debug!(now, states[now]);

    for &to in &graph[now] {
        if Some(to) == par {
            continue;
        }
        remove(now, to, states);
        add(to, now, states);

        best = min(best, dfs2(to, Some(now), graph, states));

        remove(to, now, states);
        add(now, to, states);
    }
    assert_eq!(states[now].value, ws);

    // debug!(now, states[now]);

    best
}

fn main() {
    input! {
        n: usize,
        edges: [(usize1, usize1); n-1],
        color: chars
    };
    let mut graph = vec![vec![]; n];
    for (u, v) in edges {
        graph[u].push(v);
        graph[v].push(u);
    }


    for i in 0..1 {
        let mut states = vec![];
        for i in 0..n {
            let w = ifv!(color[i] == 'B', -1, 0);
            states.push(State {
                is_white: color[i] == 'W',
                children: 0,
                best: (0, 0),
                value: vec![0, 0, w, w],
            });
        }
        dfs(i, None, &graph, &mut states);
        let ans = dfs2(i, None, &graph, &mut states);
        println!("{}", ans);
    }

    // println!("{:?}", states);
}


Measured memory_bytes: 47968