import scala.io.StdIn._
object Main extends App {
  val n = readInt
  val s = readLine
  val array = new Array[Int](n)
  (0 until n).foldLeft(0) { (acc, i) =>
    array(i) = acc + (if ('W' == s(i)) 1 else 0)
    array(i)
  }

  (n - 1 to 0 by -1).foldLeft(0) { (acc, i) =>
    array(i) = array(i) + acc + (if ('E' == s(i)) 1 else 0)
    acc + (if ('E' == s(i)) 1 else 0)
  }

  println(array.min - 1)
}
