import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math, std.container;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	int n;
	scanf("%d\n", &n);
	string s = readln().chomp;
	int[] score = new int[n];

	{
		int cur = 0;
		foreach (i; 0..n) {
			score[i] += cur;
			if (s[i] == 'W') cur++;
		}
	}
	{
		int cur = 0;
		foreach_reverse (i; 0..n) {
			score[i] += cur;
			if (s[i] == 'E') cur++;
		}
	}
	int ans = n;
	foreach (i; 0..n) {
		ans = min(ans, score[i]);
	}
	writeln(ans);
}