#include<bits/stdc++.h>
using namespace std;
#define MN 300000
char s[MN+5];
int l[MN+5],r[MN+5]; 
int main()
{
	int n,i,ans=1e9;
	scanf("%d%s",&n,s+1);
	for(i=1;i<=n;++i)l[i]=l[i-1]+(s[i]=='W');
	for(i=n;i;--i)r[i]=r[i+1]+(s[i]=='E');
	for(i=1;i<=n;++i)ans=min(ans,l[i-1]+r[i+1]);
	printf("%d",ans); 
}