#include<bits/stdc++.h>

using namespace std;

#define N 800000

int n,ans,pre[N],suf[N];
char s[N];

int main(){
	scanf("%d%s",&n,s+1);
	for (int i=1;i<=n;++i) pre[i]=pre[i-1]+(s[i]=='W');
	for (int i=n;i>=1;--i) suf[i]=suf[i+1]+(s[i]=='E');
	ans=n; for (int i=1;i<=n;++i) ans=min(ans,pre[i-1]+suf[i+1]); 
	printf("%d\n",ans);
	
	return 0;
}
			