const countChar = (s, c) => s.split(c).length - 1;

function Main (input) {
  const inputs = input.split(/\s/g);
  const a = parseInt(inputs[0]);
  const m = inputs[1];
  var rst = a;
  var i = 0;

  if (a > 3 * Math.pow(10, 5)) return;

  while (i < a) {
    var l = m.substr(0, i);
    var r = m.substr(i + 1);
    var s = countChar(l, 'W') + countChar(r, 'E');
    if (rst > s) rst = s;
    i += 1;
  }
  console.log('%s', rst);
}

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