function Main(s){
	s=s.split(/\n/);
	s[0]|=0;
	var arr=[];
	var we=0;
	for(var i=s[0]-1;i>=0;i=(i-1)|0){
		arr[i]=we;
		if(s[1][i]=="W"){we++;}
	}
	
	we=0;
	var a=1<<29;
	for(var i=0;i<s[0];i=(i+1)|0){
		arr[i]+=we;
		if(s[1][i]=="E"){we++;}
		if(a>s[0]-arr[i]-1){a=s[0]-arr[i]-1;}
	}
	console.log(a);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));