// 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.4101239897640423x):
#include <map>

#include <set>

#include <ctime>

#include <cmath>

#include <queue>

#include <stack>

#include <vector>

#include <string>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <sstream>

#include <iostream>

#include <algorithm>

#include <functional>

using namespace std;

inline int read(){int now=0;register char c=getchar();for(;!isdigit(c);c=getchar());

for(;isdigit(c);now=now*10+c-'0',c=getchar());return now;}

#define For(i, x, y) for(int i=x;i<=y;i++)  

#define _For(i, x, y) for(int i=x;i>=y;i--)

#define Mem(f, x) memset(f,x,sizeof(f))  

#define Sca(x) scanf("%d", &x)

#define Sca2(x,y) scanf("%d%d",&x,&y)

#define Sca3(x,y,z) scanf("%d%d%d",&x,&y,&z)

#define Scl(x) scanf("%lld",&x);  

#define Pri(x) printf("%d\n", x)

#define Prl(x) printf("%lld\n",x);  

#define CLR(u) for(int i=0;i<=N;i++)u[i].clear();

#define LL long long

#define ULL unsigned long long  

#define mp make_pair

#define PII pair<int,int>

#define PIL pair<int,long long>

#define PLL pair<long long,long long>

#define pb push_back

#define fi first

#define se second 

typedef vector<int> VI;

const double eps = 1e-9;

const int maxn = 3e5 + 10;

const int INF = 0x3f3f3f3f;

const int mod = 1e9 + 7; 

int N,M,K;

char str[maxn];

int pre[maxn],erp[maxn];

int main(){

	Sca(N);

	scanf("%s",str + 1);

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

		pre[i] = pre[i - 1] + (str[i] == 'W');

	}

	for(int i = N; i >= 1; i --){

		erp[i] = erp[i + 1] + (str[i] == 'E');

	}

	int sum = INF;

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

		sum = min(sum,pre[i - 1] + erp[i + 1]);

	}

	cout << sum << endl;

	return 0;

}