import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val S = sc.next

    var n = 0
    val sL = 0 +: S.map {
      case 'W' => n += 1; n
      case 'E' => n
    }
    n = 0
    val sR = 0 +: S.reverse.map {
      case 'E' => n += 1; n
      case 'W' => n
    }
    val ss = for (i <- 0 until N)
      yield sL(i) + sR(N - i - 1)
    ss.min.toString
  }
}
