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

void main()
{
	auto n = readln.strip;
	auto s = readln.strip.map!( to!dchar ).array;
	auto result = int.max;
	
	for( int index = 0; index <= s.length; index++ )
	{
		auto count = turnEast( s[ 0 .. index ].idup ) + turnWest( s[ index .. $ ].idup );
		if( count < result ) result = count;
	}
	
	writeln( result );
}

int turnEast( dstring members )
{
	static int[ dstring ] memo;
	
	switch( members.length )
	{
		case  0:
			return 0;
		case  1:
			return ( members[ 0 ] == 'E' ) ? 0 : 1;
		default:
			if( members !in memo ) memo[ members ] = turnEast( members[ 0 .. $-1 ] ) + turnEast( members[ $-1 .. $ ] );
			return memo[ members ];
	}
}

int turnWest( dstring members )
{
	static int[ dstring ] memo;
	
	switch( members.length )
	{
		case  0:
			return 0;
		case  1:
			return ( members[ 0 ] == 'W' ) ? 0 : 1;
		default:
			if( members !in memo ) memo[ members ] = turnWest( members[ 0 .. 1 ] ) + turnWest( members[ 1 .. $ ] );
			return memo[ members ];
	}
}
