#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  string s;
  cin >> N >> s;
  int cE = 0;
  for (int i = 0; i < N; i++) {
    if(s[i] == 'E') cE += 1;
  }
  
  int cost = cE;
  int m = cost;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'E') cost -= 1;
    else cost += 1;
    m = min(m,cost);
  }
  cout << m << endl;
}