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

}


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