#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int n; string s; cin >> n >> s;
	int ans = 0, p = 0;
	for (int i = 1; i < n; i++)if (s[i] == 'E')p++;
	ans = p;
	for (int i = 1; i < n; i++) {
		if (s[i] == 'E')p--;
		if (s[i - 1] == 'W')p++;
		ans = min(ans, p);
	}cout << ans << endl;
	return 0;
}