object Main extends App {  
  val n = readLine.toInt
  val list = readLine.split("").filter(_.nonEmpty)
  
  println((1 to n).toSeq.map(e => {
    list.take(e - 1).count(_ == "W") + list.drop(e).count(_ == "E")
  }).min)
}