import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

string RD() { return chomp(readln()); }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto tokens = RD.split;
	auto N = tokens[0].to!long;
	auto S = RD;

	auto e = new long[](N+1);
	auto w = new long[](N+1);
	foreach (i, c; S)
	{
		w[i+1] = w[i] + (c == 'W' ? 1 : 0); 
	}
	foreach_reverse (i, c; S)
	{
		e[i] = e[i+1] + (c == 'E' ? 1 : 0); 
	}

	long ans = long.max;
	foreach (i; 0..N)
	{
		ans = min(ans, w[i] + e[i+1]);
	}

	writeln(ans);
	stdout.flush();
}