import java.util.Scanner
import scala.util.control.Breaks

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

    val N = sc.nextInt
    val S = sc.next

    val rui_fromL, rui_fromR = Array.fill[Int](N)(0)
    (0 until N).foreach(i => {
      if (S(i) == 'W') rui_fromL(i) = 1
      else rui_fromR(i) = 1
    })

    (1 until N).foreach(i => {
      rui_fromL(i) += rui_fromL(i-1)
    })
    (0 until N-1).reverse.foreach(i => {
      rui_fromR(i) += rui_fromR(i+1)
    })

    var ans = N
    (0 until N).foreach(i => {
      ans = math.min(ans, rui_fromL(i) + rui_fromR(i) - 1)
    })

    println(ans)
  }
}