#include <bits/stdc++.h>
#define maxn 300300
using namespace std;

char v[maxn];

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