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

int n,ans=N;
char a[N];
int s[N],s2[N];

int work(int x)
{
  return s2[x-1]+s[n]-s[x];
}

signed main()
{
  cin>>n;
  scanf("%s",a+1);
  for(int i=1;i<=n;i++)
    s[i]=s[i-1]+(a[i]=='E'),
    s2[i]=s2[i-1]+(a[i]=='W');
  for(int i=1;i<=n;i++)
    ans=min(ans,work(i));
  cout<<ans;
  return 0;
}
