import std.stdio;
import std.string;

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 );
	}
	
	auto result = lc[ 0 ] + rc[ 0 ];
	foreach( i; 1 .. s.length )
	{
		auto lrc = lc[ i ] + rc[ i ];
		if( lrc < result ) result = lrc;
	}
	
	return result;
}

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