fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val s = readLine()!!
  val eCount = IntArray(n)
  val wCount = IntArray(n)
  eCount[0] = if (s[0] == 'E') 1 else 0
  wCount[0] = if (s[0] == 'W') 1 else 0
  for (i in 1 until n) {
    eCount[i] = eCount[i - 1] + if (s[i] == 'E') 1 else 0
    wCount[i] = wCount[i - 1] + if (s[i] == 'W') 1 else 0
  }
  fun count(i: Int): Int {
    val westCount = if (i == 0) 0 else wCount[i - 1]
    val eastCount = eCount[n - 1] - eCount[i]
    return westCount + eastCount
  }
  val ans = (0 until n).map { count(it) }.min()!!
  println(ans)
}
