import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val s = sc.next()

  val e = Array(n) { 0 } // east
  val w = Array(n) { 0 } // west

  for ((i, si) in s.withIndex()) {
    if (si == 'E') {
      e[i] = 1
    }
    if (si == 'W') {
      w[i] = 1
    }
  }

  var wc = 0
  var arrayW = Array(n) { 0 }
  for (i in 0 until n) {
    arrayW[i] = wc
    if (s[i] == 'W') wc++
  }
  // println(arrayW.joinToString(""))

  var ec = 0
  var arrayE = Array(n) { 0 }
  for (i in n-1 downTo 0) {
    arrayE[i] = ec
    if (s[i] == 'E') ec++
  }
  // println(arrayE.joinToString(""))

  var min = Int.MAX_VALUE
  for (i in 0 until n) {
    val tmp = arrayW[i] + arrayE[i]
    min = Math.min(min, tmp)
  }
  println(min)

}
