#include <iostream>
using namespace std;
int n, mx, c, d[300005];
string a;
int main() {
	int i;
	cin>>n>>a;
	for(i=n; i; i--) d[i] = d[i+1] + (a[i-1]=='W');
	for(i=1; i<=n; i++) {
		mx = max(mx, c + d[i+1]);
		c += (a[i-1]=='E');
	}
	cout<<n-mx-1;
	return 0;
}