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

void main()
{
	auto n = readln;
	auto s = readln.strip;
	auto result = int.max;
	
	for( int index = 0; index <= s.length; index++ )
	{
		auto xc = turnCount!( 'E' )( s[ 0 .. index ] );
		if( result < xc ) break;
		auto yc = turnCount!( 'W' )( s[ index .. $ ] );
		if( result < xc + yc ) continue;
		
		result = xc + yc;
	}
	
	writeln( result );
}

int turnCount( char direction )( in string members )
{
	static int[ string ] memo;
	
	switch( members.length )
	{
		case  0:
			return 0;
		case  1:
			return ( members[ 0 ] == direction ) ? 0 : 1;
		default:
			auto center = members.length / 2;
			if( members !in memo ) memo[ members ] = turnCount!( direction )( members[ 0 .. center ] ) + turnCount!( direction )( members[ center .. $ ] );
			return memo[ members ];
	}
}
