import java.util.Scanner

object Main {
  def solve(S: String) = {
    var l = 0
    var r = S.drop(1).count(_ == 'E')
    var res = r
    S.indices foreach { i =>
      if (i > 0 && S.charAt(i - 1) == 'W') l += 1
      if (S.charAt(i) == 'E') r -= 1
      res = math.min(res, r + l)
    }
    res
  }

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val N = sc.nextInt()
    println(solve(sc.next()))
  }
}
