#include <iostream>
#include<algorithm>
#include<cmath>
using namespace std;
#include<cstdio>
#define PI 3.1415927
char a[300000];

int main()
{
   int i,n,temp,t;
   int count1=0,count2=0;
   while(scanf("%d",&n)!=EOF)
   {
       int counts[300000]={0};
      scanf("%s",a);
       for(i=0;i<n;i++)
       {
           count1=0,count2=0;
           t=i;
          temp=i;
          for(t=0;t<temp;t++)
          {
              if(a[t]!='E')
                count1++;

          }
          for(t=temp+1;t<n;t++)
          {
              if(a[t]!='W')
                count2++;
          }
          counts[i]=count1+count2;
          //printf("%d\t",counts[i]);


       }
      sort(counts,counts+n-1);
      printf("%d\n",counts[0]);


    }
}



















