const countChar = (str, char) => str.split(char).length - 1;

function Main (input) {
  const inputs = input.split(/\s/g);
  const membersNum = parseInt(inputs[0]);
  const members = inputs[1];
  var result = membersNum;
  var index = 0;

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

  while (index < membersNum) {
    const left = members.substr(0, index);
    const right = members.substr(index + 1);
    const sum = countChar(left, 'W') + countChar(right, 'E');
    if (result > sum) result = sum;
    index += 1;
  }
  console.log('%s', result || 1);
}

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