import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const N = readln.chomp.to!long;
    const S = readln.chomp;
    auto leftList = new long[N+1];
    foreach (i; 0..N) leftList[i+1] = S[i] == 'E' ? 1 : 0;
    foreach (i; 0..N) leftList[i+1] += leftList[i];
    auto rightList = new long[N+1];
    foreach (i; 0..N) rightList[i+1] = S[i] == 'W' ? 1 : 0;
    foreach (i; 0..N) rightList[i+1] += rightList[i];

    iota(N+1).map!(i => rightList[i] + leftList[$-1] - leftList[i]).reduce!min.writeln;
}

