import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val n = in.readInt
  val s = in.readLine

  val E = s.scanLeft(0)((acc, ch) => {
    if(ch == 'W') acc + 1 else acc
  }).init

  val W = s.scanRight(0) ((ch, acc) => {
    if(ch == 'E') acc +1 else acc
  }).tail

  val ans = (0 until n)./:(Int.MaxValue)((acc, i) => {
    val res = E(i) + W(i)
    acc min res
  })

  println(ans)
}