function Main(s) {
  var s = s.split("\n");
  var n = s[0]*1, t = s[1];
  var backet = new Array(n).fill(0);
  var wCnt = 0, eCnt = 0;
  for (var i = 0; i < n; i++) {
    backet[i] += wCnt;
    if (t[i] === "W") wCnt++;
    backet[n - 1 - i] += eCnt;
    if (t[n - 1 - i] === "E") eCnt++;
  }
  var min = Infinity;
  for(var i of backet) min = Math.min(min, i);
  console.log(min);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));