object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN) = readLine.split(" ").map(_.toInt)
    val datA = readLine.split("").filterNot(_ == "")

    /*
    val ans = (0 until datA.length).map{ lead =>
      datA.take(lead).filter(_ == "W").length +
      datA.drop(lead + 1).filter(_ == "E").length
    }.min
    */

    def countLeftW(res: Vector[Int], count: Int, dat: Array[String]): Vector[Int] = {
      if (dat.isEmpty) res
      else countLeftW(res :+ count, (if (dat.head == "W") count + 1 else count), dat.tail)
    }

    def countRightE(res: Vector[Int], count: Int, dat: Array[String]): Vector[Int] = {
      if (dat.isEmpty) res.reverse
      else countRightE(res :+ count, (if (dat.last == "E") count + 1 else count), dat.init)
    }

    val ans = (countLeftW(Vector(), 0, datA) zip countRightE(Vector(), 0, datA)).map{case (a, b) => a + b}.min
    println(ans)
  }
}
