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();
    solve(s).writeln();
}

int solve(string s){
    int result = s.length.to!int;
    foreach(int leaderNum, unused; s) {
        auto persons = s[0..leaderNum].filter!((dir) => dir == 'W').array().length + s[leaderNum+1..$].filter!((dir) => dir == 'E').array().length;
        result = min(result, persons.to!int);
    }
    return result;
}