
'use strict'

function main(input) {
    input = input.split('\n')
    const troops = input[1].split('')
    const n = Number(input[0])
    let min, cnt = 0

    let countsE = [0]
    let countsW = [0]
    for (let i = 1; i <= n; i++) {
        countsW[i] = (troops[i - 1] == 'W') ? countsW[i - 1] + 1 : countsW[i - 1];
        countsE[i] = (troops[i - 1] == 'E') ? countsE[i - 1] + 1 : countsE[i - 1];
    }

    for (let i = 0; i < n; i++) {

        cnt = countsW[i] + countsE[n] - countsE[i + 1]
        min = (min < cnt) ? min : cnt
    }

    console.log(min)
}

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