'use strict'

function main(input) {
    input = input.split('\n')
    const troops = input[1].split('')
    const n = Number(input[0])
    let min, cnt = 0
    let ary = []
    let a, b;
    for (let i = 0; i < n; i++) {

        a = troops.slice(0, i)
        b = troops.slice(i + 1, troops.length)

        ary = a.filter(v => v === 'W')
        cnt = ary.length
        ary = b.filter(v => v == 'E')
        cnt += ary.length

        min = (min < cnt) ? min : cnt
    }

    console.log(min)
}

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