import scala.io.StdIn

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

  println(
    (0 until n).map { i =>
      val lh = s.slice(0, i)
      val rh = s.slice(i + 1, s.length)

      lh.count(_ == 'W') + rh.count(_ == 'E')
    }.min
  )
}