#import <stdio.h>
#import <limits.h>
#define MIN(a,b) ((a)<(b)?(a):(b))
int main() {
    long N;
    scanf("%ld",&N);
    char S[300002] = {'\0'};
    scanf("%s",S);
    long L[300002] = {0L};
    long R[300002] = {0L};
    for(long i=1;i<N;i++){
       L[i] = L[i-1] + ((S[i-1] == 'W') ? 1 : 0);
       R[N-1-i] = R[N-i] + ((S[N-i] == 'E') ? 1 : 0);
    }
    long min = LONG_MAX;
    for(long i=0;i<N;i++){
       min = MIN(min,L[i]+R[i]);
    }
    printf("%ld",min);
}
