object Main extends App {  
  val n = readLine.toInt
  val list = readLine.split("").filter(_.nonEmpty).toVector
  
  val init = list.drop(1).count(_ == "E")
  
  val min = (1 to n-1).toSeq.scan(init)((a,b) => {
    val left = if (list(b - 1) == "W") 1 else 0
    val right = if (list(b) == "E") -1 else 0
    a + left + right
  }).min
  
  println(min)
}