#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n=int(input())\n"
"s=list(input())\n"
"a=[0]*(n+1)\n"
"b=[0]*(n+2)\n"
"for i in range(n):\n"
"  a[i+1]=a[i]\n"
"  b[n-i]=b[n-i+1]\n"
"  if s[i]=='W':\n"
"    a[i+1]+=1\n"
"  if s[n-i-1]=='E':\n"
"    b[n-i]+=1\n"
"print(min(a[i]+b[i]-1for i in range(1,n+1)))\n"
"\"";
  system(s);
  return 0;
}            