function main(input) {
    var N = input[0]-0;
    var list = input[1].split("");
    var lmap = [];
    var rmap = [];
    for(var i=0;i<N;i++){
        lmap[i] = lmap[i-1]||0;
        rmap[N-i-1] = rmap[N-i]||0;
        if(list[i] == "W"){
            lmap[i]++;
        }
        if(list[N-i-1] == "E"){
            rmap[N-i-1]++;
        }
    }
    var ans = N;
    for(var i=0;i<N;i++){
        ans = Math.min(ans, lmap[i]+rmap[i]-1);
    }
    console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));
