#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0, ret = 1e9;
  for (int i = 1; i < n; ++i) {
    if (s[i] == 'E') ans++;
  }
  ret = min(ans, ret);
  for (int i = 1; i < n; ++i) {
    if (s[i - 1] == 'W') ans++;
    if (s[i] == 'E') ans--;
    ret = min(ans, ret);
  }
  cout << ret << endl;
}