'use strict'

function main(input) {
    input = input.split("\n");
    const N = parseInt(input[0]);
    const S = input[1];
    let w = 0;
    let e = 0;
    for (let i = 0; i < N; i++) {
        if (S[i] === 'W')
            w++;
        else
            e++;
    }

    let num = e - ((S[0] === 'E') ? 1 : 0);
    let min = num;
    for (let i = 1; i < N; i++) {
        let left = S[i-1];
        let newleader = S[i];
        if (left === 'W')
            num++;
        if (newleader === 'E')
            num--;
        if (min > num)
            min = num;
    }
    console.log(min);
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'));
