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

int main(){
    int N;
    cin >> N;

    char s[N];
    int bw=0, fe=0, min;
    for(int i=0;i<N;i++){
        cin >> s[i];
        if(i>0 && s[i] == 'E') fe++;
    }
    min = fe;
    for(int i=1;i<N;i++){
        if(s[i-1]=='W') bw++;
        if(s[i]=='E') fe--;
        if((fe+bw)<min) min = fe + bw;
    }
    cout << min <<"\n";
    return 0;
}
