function main(input) {
	var a = input.split('\n');
	var N = parseInt(a[0], 10);
	var S = a[1];
	var countmin = N;
	var countW = 0;
	var countE = 0;
	for(i=1;i<N;i++){
		var S1 = S.slice(i,i+1);
		if(S1==='W'){
			countW += 1;
		} else if(S1==='E'){
			countE += 1;
		}
	}
	countX = countE;
	countmin = countX;
	for(i=0;i<N;i++){
		var S0 = S.slice(i,i+1);
		if(i<N-1){
			var S1 = S.slice(i+1,i+2);
			if(S1 === 'E'){
				countX -= 1;
			}
		}
		if(S0 === 'W'){
			countX += 1;
		}
		countmin = Math.min(countmin,countX);
	}
	console.log(countmin);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));