const main = function(input){
  var str = input.split("\n")[1];
  var len = str.length;
  var min = 3*Math.pow(10,5);
  
  var rightCount = 0;
  var leftCount = 0;
  for(var i=0;i<len;i++){
    if(str[i] === "E") rightCount++;
  }
  var left = "";
  for(var i=0;i<len;i++){
  	var leader = str[i];
    if(leader==="E")rightCount--;
    
    var count = rightCount+leftCount;
    if(min>count) min = count;
    
    if(leader==="W")leftCount++;
    left+=leader;
  }
  
  console.log(min);
}


main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));