#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int a = 0;
  int b = 0;
  int bl = 0;
  int wh = 0;
  int MIN = 0;
  string S;
  cin >> N >> S;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'W') wh++;
  }
  MIN = wh + bl;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'W')
      bl--;
    else
      wh++;
    if (MIN > wh + bl) MIN = wh + bl;
  }
  cout << MIN;
  return 0;
}
