#include<bits/stdc++.h>
#define int long long
using namespace std;
int sum[300000];
signed main(){
    int  n;
    string s;
    cin>>n>>s;
    for(int i=0;i<n;i++)
        sum[i+1]=sum[i]+(s[i]=='E');
    int ans=300000;
    for(int i=0;i<n;i++)
        ans=min(ans,sum[n]-sum[i+1]+i-sum[i]);
    cout<<ans<<endl;
}
