/**
*   @author Mustafa Khaled.
**/
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll;

#define REP(i, n) for(int i = 0 ; i < n ; ++i )

string to_string(string s){return '"' + s + '"';}string to_string(const char* s){return to_string((string) s);}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v){bool first = true;string res = "{";for (const auto &x : v){if (!first){res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void debug_out(){cerr << endl;}template <typename Head, typename... Tail>void debug_out(Head H, Tail... T){cerr << " " << to_string(H);debug_out(T...);}/*input*/inline void in(const char *t) {}template <typename Head, typename... Tail>inline void in(const char *t,Head &H, Tail&... T){scanf(t,&H);in(t,T...);}
#define D(...)    in(  "%d",__VA_ARGS__);
#define LLD(...)  in("%lld",__VA_ARGS__);

#ifndef ONLINE_JUDGE
    #define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define dbg(...) {}
#endif
/// start driven program
const int OO = 0x3f3f3f3f, N=3e5+7  , MOD= 1000000007;

int beforW[N];
int afterE[N];
char s[N];
int main(){
    int n ; D(n); scanf(" %s",s);
    for ( int i =0;  i<n ; ++i){
        if(s[i]=='W'){
            beforW[i+1]=1;
        }
    }
    for(int i=0 ; i < n ; ++i){
        beforW[i+1]+=beforW[i];
    }


    for ( int i =n-1;  ~i ; --i){
        if(s[i]=='E'){
            afterE[i+1]=1;
        }
    }
    for ( int i =n-1;  ~i ; --i){
        afterE[i+1]+=afterE[i+2];
    }
    int mn =OO , x=0;

    for(int i=0 ; i < n ; ++i){
        x=(beforW[i+1]-(s[i]=='W')) + (afterE[i+1]-(s[i]=='E') );
        dbg(i , x);
        mn = min(mn ,x);
    }

    printf("%d\n" , mn);

}
