"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const S = arg[1].split("");
    
    const countW = S.filter(s=>s==="W").length;
    const countE = N - countW;
    
    const left  = {W: 0, E: 0};
    const right = {W: countW, E: countE};
    
    let answer = Infinity;
    
    for(let i=0; i<N; i++) {
        let now = S[i];
        
        if(now === "W") right.W--;
        if(now === "E") right.E--;
        
        answer = Math.min(answer, right.E + left.W);
        
        if(now === "W") left.W++;
        if(now === "E") left.E++;
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));