import java.util.Scanner;

object Main{
  def main(args: Array[String]){
    val sc = new Scanner(System.in);
    val n = sc.nextInt;
    sc.nextLine;
    val s: String = sc.nextLine;

    var countW: Array[Int] = new Array(n+1);
    var countE: Array[Int] = new Array(n+1);

    for(i <- 1 to n){
      countW(i) = countW(i-1);
      countE(i) = countE(i-1);
      s(i-1) match{
        case 'W' => countW(i) += 1;
        case 'E' => countE(i) += 1;
      }
    }

    println((for(i <- 1 to n) yield (countW(i-1) + countE(n) - countE(i))).min);
  }
}
