"use strict";
const input = require("fs").readFileSync("/dev/stdin", "utf8");
const len = input.split("\n")[0];
const ary = input.split("\n")[1].split("").map(e => [e, 0]);
let count = 0;
for (let a of ary.reverse()) {
    if (a[0] === "E") { count ++ };
    a[1] = count;
}
count = 0;
for (let a of ary.reverse()) {
    if (a[0] === "W") { count ++ };
    a[1] += count - 1;
}

console.log(ary.reduce((p, c) => p[1] > c[1] ? c : p)[1]);