object Main extends App {  
  val n = readLine.toInt
  val list = readLine.split("").filter(_.nonEmpty).zipWithIndex
  
  println((0 to n-1).toSeq.map(k => {
    list.count{case (e, index) => (index < k && e == "W") || (index > k && e == "E")}
  }).min)
}