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

function Main (input) {
  const i = input.split(/\s/g);
  const mn = parseInt(i[0]);
  const m = i[1];
  var r = mn;
  var idx = 0;

  while (idx < mn) {
    const l = m.substr(0, idx);
    const r = m.substr(idx + 1);
    const s = countChar(l, 'W') + countChar(r, 'E');
    if (r > s) r = s;
    idx += 1;
  }
  console.log('%s', r || 1);
}

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