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