'use strict'

function main(s) {

  const lines  = s.split('\n')[1].split('');

  let count = 300000;
  for (let i = 0; i < lines.length; i++) {
    const left  = lines.slice(0, i).filter(p => p === 'W').length;
    const right = lines.slice(i + 1).filter(p => p === 'E').length;
    const result = left + right;
    count = Math.min(count, result)
  }

  console.log(count);
}

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