unittest
{
	assert( [ "5", "WEEWW" ].solve == 1 );
	assert( [ "12", "WEWEWEEEWWWE" ].solve == 4 );
	assert( [ "8", "WWWWWEEE" ].solve == 3 );
}



import std.algorithm;
import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto s = input.front.to!( dchar[] );
	
	auto wts = new long[ 1 + s.length ];
	foreach( i, c; s )
	{
		wts[ i + 1 ] = wts[ i ] + ( c == 'W' );
	}
	auto ets = new long[ 1 + s.length ];
	foreach_reverse( i, c; s )
	{
		ets[ i ] = ets[ i + 1 ] + ( c == 'E' );
	}
	
	auto ans = long.max;
	foreach( i; 0L .. s.length.signed )
	{
		ans = min( ans, wts[ i ] + ets[ i ] );
	}
	
	return ans;
}
