import scala.io.StdIn

object Main extends App {
  val n = StdIn.readLine().toInt
  val s = StdIn.readLine()

  val a = Array.ofDim[Int](n)

  (0 until n).foldLeft(0) { (acc, i) =>
    a(i) = acc + (if ('W' == s(i)) 1 else 0)
    a(i)
  }

  (n - 1 to 0 by -1).foldLeft(0) { (acc, i) =>
    a(i) = a(i) + acc + (if ('E' == s(i)) 1 else 0)
    acc + (if ('E' == s(i)) 1 else 0)
  }
  //println(a.toList.mkString(" "))
  println(a.min - 1)
}