#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn=3e5+10;
int n,ans,sum[maxn],summ[maxn];
char s[maxn];

int main(){
	cin>>n>>(s+1);
	for(int i=1;i<=n;++i)
		sum[i]=sum[i-1]+(s[i]=='W');
	for(int i=n;i;--i)
		summ[i]=summ[i+1]+(s[i]=='E');
	ans=n;
	for(int i=1;i<=n;++i)
		ans=min(ans,sum[i-1]+summ[i+1]);
	cout<<ans<<endl;
	return 0;
}