#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
char lx[N];

int main() {
  int n;
  scanf("%d%s", &n, lx + 1);
  int pos = 0;
  for(int i = 1; i <= n; ++i) {
    if(lx[i] == 'E') pos++;
  }
  int ans = n, tmp = 0;
  for(int i = 1; i <= n; ++i) {
    if(lx[i] == 'E') pos--;
    ans = min(ans, pos + tmp);
    if(lx[i] == 'W') tmp++;
  }
  printf("%d\n", ans);
  return 0;  
}