process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    var n = parseInt(input[0], 10);
    var s = input[1].split('');

    var ww = 0;
    var we = 0;
    var ew = 0;
    var ee = 0;
    var rightCharCount = {};
    var leftCharCount = {};

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

        if (s[i] === 'W') {
            ew++;
        }
        else {
            ee++;
        }
    }

    var change = 0;
    var ans = Number.MAX_SAFE_INTEGER;

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

        if (s[i] === 'W') {
            ew--;
        }
        else {
            ee--;
        }

        change = ww + ee;
        ans = Math.min(ans, change);

        if (s[i] === 'W') {
            ww++;
        }
        else {
            we++;
        }
    }

    console.log(ans);

    return 0;
}
