
import std.algorithm;
import std.stdio;
import std.string;
import std.range;

void main()
{
	auto n = readln;
	auto s = readln.strip;
	
	writeln( solve( s ) );
}

int solve( in string s )
{
	auto lc = new int[ s.length ];
	lc[ 0 ] = 0;
	foreach( i; 1 .. s.length )
	{
		lc[ i ] = lc[ i - 1 ] + ( s[ i - 1 ] == 'E' ? 0 : 1 );
	}
	
	auto rc = new int[ s.length ];
	rc[ $-1 ] = 0;
	foreach_reverse( i; 0 .. s.length-1 )
	{
		rc[ i ] = rc[ i + 1 ] + ( s[ i + 1 ] == 'W' ? 0 : 1 );
	}
	
	return zip( lc, rc ).map!( a => a[ 0 ] + a[ 1 ] ).reduce!( min );
}

unittest
{
	assert( solve( "WEEWW" ) == 1 );
	assert( solve( "WEWEWEEEWWWE" ) == 4 );
	assert( solve( "WWWWWEEE" ) == 3 );
}
