import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

bool chmin(t)(ref t a, t b) {
  if (b < a) {
    a = b;
    return true;
  } else {
    return false;
  }
}

void main() {
  int N = readln.chomp.to!int;
  string S = readln.chomp;
  int[] dp = new int[](N);

  foreach (l; 0..N) {
    foreach (i; 0..l) {
      if (S[i] == 'W') {
        dp[l] += 1;
      }
    }

    foreach (i; l+1..N) {
      if (S[i] == 'E') {
        dp[l] += 1;
      }
    }
  }

  int min = int.max;

  foreach (i, a; dp) {
    chmin(min, a);
  }

  writeln(min);
}
