const fs = require("fs");

function Main(input){
    input = input.split("\n");
    var N = input[0];
    var direction = input[1].split("");
    var ans=[];
    var max = 0;
    var countw = 0;
    for(i = 1; i <= N-1; i++){
        if(direction[i] == "E"){
            max ++;
        }   
    }
    ans[0] = max;
    
    for(j = 1; j <= N-1; j++){
        if(direction[j] == "E"){
            max--;
        }
        if(direction[j-1] == "W"){
            max++;
        }
        ans[j] = max;
    }
    console.log(Math.min.apply(null, ans));
}

Main(fs.readFileSync("/dev/stdin", "utf8"))