function Main (input) {
  const members = input.split(/\s/g)[1];
  const membersNum = members.length;
  const results = new Array(membersNum).fill('').map((value, index) => {
    const left = members.slice(0, index);
    const right = members.slice(index + 1, membersNum);
    const leftMatches = left.match(/W/g);
    const rightMatches = right.match(/E/g);
    const leftNum = leftMatches ? leftMatches.length : 0;
    const rightNum = rightMatches ? rightMatches.length : 0;
    return leftNum + rightNum;
  });
  console.log('%s', Math.min(...results));
}

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