function Main(s){
  s = s.split("\n");
  var n = +s[0];
  s = s[1];
  var a = [0];
  for(var i = 0; i < n; i++){
    if(s[i] === "E")a[i+1] = a[i] + 1;
    else a[i+1] = a[i];
  }
  ans = 9e9;
  for(i = 0; i < n; i++){
    ans = Math.min(ans, a[n] - a[i+1] + i - a[i] + a[0]);
  }
  console.log(ans);
}

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