#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5;
int n,u[N],d[N],ans;
char s[N];
int main(){
	scanf("%d",&n);
	ans=n-1;
	scanf("%s",s+1);
	for (int i=1;i<=n;++i)
		u[i]=u[i-1]+(s[i]=='W');
	for (int i=n;i>=1;--i)
		d[i]=d[i+1]+(s[i]=='E');
	for (int i=1;i<=n;++i)
		ans=min(ans,u[i-1]+d[i+1]);
	printf("%d\n",ans);
}