import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main()
{
  int n = readln.chomp.to!int;
  string s = readln.chomp;
  int leftW = 0;
  int rightE = 0;
  foreach (c; s) {
    if (c == 'E') {
      ++rightE;
    }
  }
  int ans = int.max;
  foreach (c; s) {
    if (c == 'E') {
      --rightE;
    }
    ans = min(ans, leftW + rightE);
    if (c == 'W') {
      ++leftW;
    }
  }
  ans.writeln;
}
