"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const S = arg[1].split("");
    
    // リーダーより右は全員Wになる
    // 左は全員Eになるべき
    
    let W = 0;
    let E = S.filter(n=>n === "E").length;
    
    let answer = Infinity;
    
    for(let i=0; i<N; i++) {
        let toE = 0;
        let toW = 0;
        
        if(E > 0) {
            toW = E;
        }
        
        if(W > 0) {
            toE = W;
        }
        
        const temp = toE + toW;
        answer = Math.min(answer, temp);
        
        if(S[i] === "W") {
            W++;
        } else {
            E--;
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));