#include <bits/stdc++.h>
using namespace std;
int n, ans = 1e9;
int b[1000010], w[1000010];
char a[1000010];
inline int read() {
  int x = 0, t = 1, c;
  while (!isdigit(c = getchar()))
    if (c == '-') t = -1;
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  return x * t;
}
int main() {
  n = read();
  scanf("%s", a + 1);
  for (int i = 1; i <= n; i++) {
    if (a[i] == 'B') b[i]++;
    b[i] += b[i - 1];
  }
  for (int i = n; i >= 1; i--) {
    if (a[i] == 'W') w[i]++;
    w[i] += w[i + 1];
  }
  for (int i = 0; i <= n; i++) ans = min(ans, b[i] + w[i + 1]);
  printf("%d\n", ans);
  return 0;
}
