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

void main()
{
	auto n = readln;
	auto s = readln.strip;
	auto lts = new int[ s.length ];
	auto rts = new int[ s.length ];
	auto result = int.max;
	
	lts[ 0 ] = 0;
	rts[ $-1 ] = 0;
	
	for( int index = 1; index < s.length; index++ )
	{
		lts[ index ] = lts[ index - 1 ] + ( s[ index - 1 ] == 'E' ? 0 : 1 );
	}
	for( int index = cast( int ) s.length-2; 0 <= index; index-- )
	{
		rts[ index ] = rts[ index + 1 ] + ( s[ index + 1 ] == 'W' ? 0 : 1 );
	}
	for( int index = 0; index < s.length; index++ )
	{
		result = min( result, lts[ index ] + rts[ index ] );
	}
	
	writeln( result );
}
