#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

ll bit[800010];
ll u;
void bitinit(ll n){
    ll y=1;
    rep(i,0,69){
        
        if(y>=n){
            u=y;
            break;
        }
        y*=2;
    }
    fill(bit,bit+u+10,0);
}
void add(ll n,ll x){
    ll i=n;
    bit[i]+=x;
    bit[i]%=mod;
    while(i<u){
        i+=i&(-i);
        bit[i]+=x;
        bit[i]%=mod;
    }
}
ll sum(ll n){
    ll i=n;
    ll ret=0;
    while(i>0){
        ret+=bit[i];
        i-=i&(-i);
        ret%=mod;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    vector<int> v[n+1];
    int a[n-1],b[n-1];
    rep(i,0,n-1){
        cin>>a[i]>>b[i];
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
    }
    string s;cin>>s;
    int uu=0;
    rep(i,0,n){
        if(s[i]=='W')uu++;
    }
    if(uu<=1){
        cout<<uu<<endl;
        return 0;
    }
    queue<int> q;
    rep(i,1,n+1){
        if(v[i].size()==1&&s[i-1]=='B')q.push(i);
    }
    bool bo[n+1];
    fill(bo,bo+n+1,false);
    int cnt[n+1];
    fill(cnt,cnt+n+1,0);
    while(q.size()>0){
        int now=q.front();q.pop();
        bo[now]=true;
        rep(i,0,v[now].size()){
            int ne=v[now][i];
            if(bo[ne])continue;
            if(s[ne-1]=='W')continue;
            cnt[ne]++;
            if(v[ne].size()==cnt[ne]+1)q.push(ne);
        }
    }
    rep(i,1,n+1)v[i].clear();
    rep(i,0,n-1){
        if(bo[a[i]]||bo[b[i]])continue;
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
    }
    int dif[n+1];
    rep(i,1,n+1){
        if(bo[i])continue;
        if(s[i-1]=='W'){
            if(v[i].size()%2==1)dif[i]=-1;
            else dif[i]=1;
        }
        else{
            if(v[i].size()%2==1)dif[i]=1;
            else dif[i]=-1;
        }
    }
    int dp[n+1];
    int k=0;
    rep(i,1,n+1){
        if(bo[i]==false){
            k+=v[i].size();
            if(dif[i]==1)k++;
        }
    }
    int ne;
    rep(i,1,n+1){
        if(s[i-1]=='W'){
            ne=i;
            break;
        }
    }
    v[ne].push_back(-1);
    q.push(ne);
    int pa[n+1];
    pa[ne]=-1;
    int maa=-1000000000;
    while(q.size()>0){
        int now=q.front();q.pop();
        rep(i,0,v[now].size()){
            int u=v[now][i];
            if(u==pa[now])continue;
            q.push(u);
            pa[u]=now;
        }
    }
    //rep(i,1,n+1)cout<<pa[i]<<" ";
   // cout<<endl;return 0;
    rep(i,1,n+1){
        if(bo[i])continue;
        if(v[i].size()==1){
            q.push(i);
            dp[i]=0;
        }
    }
    fill(cnt,cnt+n+1,0);
    while(q.size()>0){
        int now=q.front();q.pop();
        if(v[now].size()!=1){
            int ma=-1000000000;
            vector<int> w;
            rep(i,0,v[now].size()){
                int u=v[now][i];
                if(u==pa[now])continue;
                ma=max(ma,dp[u]);
                w.push_back(dp[u]);
            }
            if(dif[now]==1)ma+=2;
            dp[now]=ma;
            sort(w.begin(),w.end(),greater<int>());
            if(w.size()>=2){
                int y=w[0]+w[1];
                if(dif[now]==1)y+=2;
                maa=max(maa,y);
            }
        }
        if(now==ne)break;
        cnt[pa[now]]++;
        if(v[pa[now]].size()==cnt[pa[now]]+1)q.push(pa[now]);
    }
    maa=max(maa,dp[ne]);
    cout<<k-maa<<endl;
   // rep(i,1,n+1)cout<<dif[i]<<" ";
 //   cout<<maa<<endl;
}


Measured memory_bytes: 9720