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

int solve (int n)
{
	readln;
	auto s = readln.strip;

	auto d = new int [n + 1];
	d[0] = 0;
	foreach (i; 0..n)
	{
		d[i + 1] = d[i] + (s[i] != 'E');
	}
	debug {writeln (d);}

	auto f = new int [n + 1];
	f[n] = 0;
	foreach_reverse (i; 0..n)
	{
		f[i] = f[i + 1] + (s[i] != 'W');
	}
	debug {writeln (f);}

	int res = n;
	foreach (i; 0..n)
	{
		res = min (res, d[i] + f[i + 1]);
	}
	return res;
}

void main ()
{
	int n;
	while (readf (" %s", &n) > 0)
	{
		writeln (solve (n));
	}
}
