#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n,i=0,e=0,w=0,s=1e9,a[300003];
	char c[300003];
	for(cin>>n;i<n;cin>>c[i],a[i]=w,w+=c[i++]==87);
	for(;i>0;s=min(s,a[--i]+e),e+=c[i]==69);
	cout<<s<<endl;
}