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