#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int main() {
  int N; string S;
  cin >> N >> S;

  int cnt_e = 0, cnt_w = 0;
  for (char c : S)
    if (c == 'E') cnt_e++;

  int ans = 1001001001;

  for (int i = 0; i < N; ++i) {
    if (S.at(i) == 'E') cnt_e--;
    ans = min(ans, cnt_e + cnt_w);
    if (S.at(i) == 'W') cnt_w++;
  }

  cout << ans << endl;
  return 0;
}
