import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }

void main() {
    int n = readint();
    string s = readln.chomp;

    int[] a = new int[300010];
    int[] b = new int[300010];
    foreach (i, c; s) {
        a[i] += (c == 'E');
        b[i] += (c == 'W');
    }
    foreach (i; 0..n - 1) {
        a[i+1] += a[i];
        b[i+1] += b[i];
    }

    int ans = a[n - 1] - a[0];
    foreach (i; 1..n) {
        int x = b[i - 1] + (a[n - 1] - a[i]);
        ans = min(ans, x);
    }
    writeln(ans);

    string _ = readln;
}
