function main(input) {
  input = input.split('\n');
  var n = Number(input[0]);
  var seq = input[1];
  var minChange = Number.MAX_VALUE;
  var change = 0;
  for (var i = 1; i < n; i++) {
    if (seq[i] === 'E') change += 1;
  }
  var prev = seq[0];
  for (i = 1; i < n; i++) {
    if (prev === 'W') {
      change += 1;
    }
    if (seq[i] === 'E') {
      change -= 1;
    }
    minChange = Math.min(change, minChange);
    prev = seq[i];
  }
  console.log(minChange);
}

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