#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=400000;
char a[MAXN];
int main()
{
    int n;
    int minn=MAXN;
    cin>>n;
    for(int i=0;i<n;i++)
       cin>>a[i];
    for(int i=0;i<n;i++)
    {
        int sum=0;
        for(int j=0;j<i;j++)
        {
            if(a[j]=='W')
                sum+=1;
        }
        for(int j=n-1;j>i;j--)
        {
            if(a[j]=='E')
              sum+=1;
        }
        minn=min(minn,sum);
    }
    cout<<minn<<endl;
    return 0;
}