// Slower C++ solution:
/*

    Name: Attention

*/

#include "stdio.h"

bool debug=false;

int main()

{

    bool isstarteast=false,isbuffeast,iscureast;//west = false east = true

    int numamong[300010]={};

    int N,numberofdiffer=0;

    char buffer;

    scanf("%d",&N);

    scanf(" %c",&buffer);

    if(buffer=='E') isstarteast=true;

    else{

        numamong[1]=1;

        numberofdiffer++;

        iscureast=false;

    }

    //numberofdiffer is divisible by 2 when it is currently east

    for(int i=1;i<N;i++)

    {

        scanf(" %c",&buffer);

        if(buffer=='E') isbuffeast=true;

        else            isbuffeast=false;

        if(numberofdiffer==0)

        {

            if(!isbuffeast)

            {

                numamong[1]=1;

                numberofdiffer++;

                iscureast=false;

            }

            continue;

        }

        if(isbuffeast==iscureast)

        {

            numamong[numberofdiffer]++;

            continue;

            printf("hi");

        }

        numberofdiffer++;

        numamong[numberofdiffer]=1;

        iscureast=!iscureast;

    }

    if(numberofdiffer%2) numberofdiffer--;

    if(debug)

    {

        for(int i=1;i<=numberofdiffer;i++)

        {

            if(i%2==0)  printf("E ");

            else        printf("W ");

            printf("%d\n",numamong[i]);

        }

    }

    int mins,caseallW=0;

    for(int i=2;i<=numberofdiffer;i+=2)

    {

        caseallW+=numamong[i];

    }

    mins=caseallW;

    int curcase=caseallW;

    for(int i=1;i<numberofdiffer;i+=2)

    {

        curcase+=numamong[i];

        curcase-=numamong[i+1];

        if(debug)

            printf("curcase of %d = %d\n",i,curcase);

        if(mins>curcase)

        {

            mins=curcase;

        }

    }

    printf("%d",mins);

}




// Faster C++ solution for the same problem (measured speedup: 1.3893705828204208x):
#include <iostream>

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <cmath>

#include <queue>

#include <stack>

#include <map>

#include <set>

#include <vector>

#include <iomanip>

#define ALL(x) (x).begin(), (x).end()

#define rt return

#define dll(x) scanf("%I64d",&x)

#define xll(x) printf("%I64d\n",x)

#define sz(a) int(a.size())

#define all(a) a.begin(), a.end()

#define rep(i,x,n) for(int i=x;i<n;i++)

#define repd(i,x,n) for(int i=x;i<=n;i++)

#define pii pair<int,int>

#define pll pair<long long ,long long>

#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

#define MS0(X) memset((X), 0, sizeof((X)))

#define MSC0(X) memset((X), '\0', sizeof((X)))

#define pb push_back

#define mp make_pair

#define fi first

#define se second

#define eps 1e-6

#define gg(x) getInt(&x)

#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;

using namespace std;

typedef long long ll;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}

inline void getInt(int* p);

const int maxn=1000010;

const int inf=0x3f3f3f3f;

/*** TEMPLATE CODE * * STARTS HERE ***/

char s[maxn];

int n;

int a[maxn];

int b[maxn];

int suma[maxn];

int sumb[maxn];

int main()

{

    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);

    //freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);  

    gbtb;

    cin>>n;

    cin>>s+1;

    repd(i,1,n)

    {

        if(s[i]=='W')

        {

            a[i]=1;

        }else

        {

            a[i]=-1;

        }

    }

    repd(i,1,n)

    {

        suma[i]=suma[i-1];

        // sumb[i]=sumb[i-1];

        if(a[i]==1)

        {

            suma[i]++;

        }



    }

    for(int i=n;i>=1;i--)

    {

        sumb[i]=sumb[i+1];

        if(a[i]==-1)

        {

            sumb[i]++;

        }

    }

    int ans=inf;

    // repd(i,1,n)

    // {

    //     cout<<i<<" "<<suma[i]<<" "<<sumb[i]<<endl;

    // }

    repd(i,1,n)

    {

        // cout<<i<<" "<<sumb[i+1]+suma[i-1]<<endl;

        ans=min(ans,sumb[i+1]+suma[i-1]);

    }

    cout<<ans<<endl;

    

    return 0;

}



inline void getInt(int* p) {

    char ch;

    do {

        ch = getchar();

    } while (ch == ' ' || ch == '\n');

    if (ch == '-') {

        *p = -(getchar() - '0');

        while ((ch = getchar()) >= '0' && ch <= '9') {

            *p = *p * 10 - ch + '0';

        }

    }

    else {

        *p = ch - '0';

        while ((ch = getchar()) >= '0' && ch <= '9') {

            *p = *p * 10 + ch - '0';

        }

    }

}