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

int n, s[300004];
string a;

int sum(int x, int y) {
	if (x>y) return 0;
	if (x) return s[y] - s[x-1];
	else return s[y];
}

int main() {
	cin >> n >> a;

	for (int i=0; i<n; i++) {
		s[i] = (a[i] == 'W');
		if (i) s[i] += s[i-1];
	}

	int ans = 1e8;
	for (int i=0; i<n; i++) {
		ans = min(ans, sum(0, i-1) + (n-i-1) - sum(i+1, n-1));
	}

	cout << ans;
}
