object Main {

  class Solver(n: Int, s: String) {

    def getInitialCount: Int = {
      val eIdx = 0 to n-1 filter { i => s.charAt(i) == 'E' }
      eIdx.length
    }

    def getCounts: (Int, Int) => Vector[Int] = (i, preCount) => i match {
      case `n` => Vector[Int]()
      case _ => {
        val t = if (s(i-1) == 'W') preCount + 1 else preCount
        val count = if (s(i) == 'E') t - 1 else t
        count +: getCounts(i+1, count)
      }
    }

    def solve = {
      val initialCount = getInitialCount;
      val counts = initialCount +: getCounts(1, initialCount);
      counts.min;
    }

  }

  def main(args: Array[String]) {
    val n = io.StdIn.readLine().toInt;
    val s = io.StdIn.readLine();
    val solver = new Solver(n, s);
    println(solver.solve);
  }

}
