function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	var N = parseInt(input[0], 10);
	var S = input[1][0];
	var vec_S = S.split("");
	var tmpAns = 0;
	for (var i = 0; i < N; i++){
		if (vec_S[i] !== "W") tmpAns ++;
	}
	var ans = tmpAns;
	for (var i = 0; i < N; i++){
		if (vec_S[i] === "E") tmpAns --;
		else tmpAns ++;
		ans = Math.min(ans, tmpAns);
	}
	console.log(ans);
}
  
Main(require("fs").readFileSync("/dev/stdin", "utf8")); 