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[][](2, N);

  foreach (i, ch; S) {
    if (ch == 'W') {
      if (i > 0) {
        dp[0][i] = dp[0][i - 1] + 1;
      } else {
        dp[0][i] = 1;
      }
    } else {
      if (i > 0) {
        dp[0][i] = dp[0][i - 1];
      } else {
        dp[0][i] = 0;
      }
    }
  }

  foreach_reverse (i, ch; S) {
    if (ch == 'E') {
      if (i < N - 1) {
        dp[1][i] = dp[1][i + 1] + 1;
      } else {
        dp[1][i] = 1;
      }
    } else {
      if (i < N - 1) {
        dp[1][i] = dp[1][i + 1];
      } else {
        dp[1][i] = 0;
      }
    }
  }

  int[] ans = new int[](N);

  foreach (i; 0..N) {
    ans[i] = dp[0][i] + dp[1][i];
  }

  int min = int.max;

  foreach (a; ans) {
    chmin(min, a);
  }

  writeln(min - 1);
}
