#include<iostream>
#include<algorithm>
#include<string>

using namespace std;
int n;
string s;
int r[324000];
int main(){
	cin >> n;
	cin >> s;
	for(int i = 0;i < n;i++){
		if(s[i] == 'E')r[i] = 1;
		if(i)r[i] += r[i-1];
	}
	int ans = 1 << 28;
	for(int i = 0;i < n;i++){
		int tmp = 0;
		if(i)tmp = i - r[i-1];
		tmp += r[n-1] - r[i];
		ans  = min(ans, tmp);
	}

	cout << ans << endl;
	return 0;
}