import std.stdio;
import std.range;
import std.array;
import std.algorithm;
import std.string;
import std.conv;

void main(){
    auto n = readln();
    auto s = readln().chomp();
    solve(s).writeln();
}

int solve(string s){
    int allE = s.filter!((ch) => ch == 'E').array().length.to!int;
    int allW = s.filter!((ch) => ch == 'W').array().length.to!int;
    int checkedE;
    int checkedW;
    int[] collection;
    foreach(dir; s) {
        if(dir == 'E'){
            checkedE++;
        }else{
            checkedW++;
        }
        if(dir == 'W'){
            collection ~= checkedW + (allE - checkedE) - 1;
        }else{
            collection ~= checkedW + (allE - checkedE);
        }
        // writefln("checkedE:%s chekedW:%s allE:%s leader:%s collection:%s", checkedE, checkedW, allE, dir, collection);
    }
    return collection.sort!("a < b")[0];
}