'use strict'

function main(s) {

  s = s.split('\n');
  const n = Number(s[0]);
  const str = s[1].split('');
  const cum = [0]

  for (let i = 0; i < n; i++) {
    if (str[i] === 'W') {
      cum[i + 1] = cum[i] + 1;
    } else {
      cum[i + 1] = cum[i];
    }
  }

  let result = 3e5;
  for (let i = 0; i < n; i++) {
    const left  = cum[i];
    const right = (n - i - 1) - (cum[n] - cum[i + 1])
    result = Math.min(result, left + right);
  }

  console.log(result);
}

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