
'use strict'
function main (input) {
  input = input.split('\n')
  const troops = input[1].split('')
  const n = Number(input[0])
  let countsW = [0]
  for (let i = 1; i <= n; i++) {
    countsW[i] = (troops[i - 1] == 'W') ? countsW[i - 1] + 1 : countsW[i - 1]
  }
  let min, cnt = 0
  for (let i = 0; i < n; i++) {
      cnt = n - (i + 1) - (countsW[n] - countsW[i + 1]) + countsW[i]
    min = (min < cnt) ? min : cnt
  }
  console.log(min)
}

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