import java.util.Scanner

object Main {
  val sc = new Scanner(System.in)
  def main(args: Array[String]) {
    val n = sc.nextInt
    val s = sc.next
    var (leftE, rightW) = (0, s.count(_ == 'W'))
    var max = leftE + rightW
    for (i <- 0 until n) {
      s(i) match {
        case 'E' => leftE += 1
        case 'W' => rightW -= 1
      }
      max = math.max(max, leftE + rightW)
    }
    println(n - max)
  }
}
