const main = function(input){
  var str = input.split("\n")[1];
  var min = 3*Math.pow(10,5);
  var convert = {
    "E":"W",
    "W":"E"
  };
  
  for(var i=0;i<str.length;i++){
    var leader = str[i];
    var left = i===0 ? "" : str.slice(0,i);
    var right = str.slice(i+1);
	var newRight = "";
    for(var j=0;j<right.length;j++){
      newRight += convert[right[j]];
    }
    var newStr = newRight+left;    
    var count = 0;
    
    for(var j=0;j<newStr.length;j++){
    	if(newStr[j]!=="E") count++;
    }
    if(min>count) min = count;
  }
  console.log(min);
}


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