object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  sc.nextLine
  var s = sc.nextLine.toCharArray

  var ans = 1001001001
  for (i <- 0 until n) {
    val sum = s.slice(0, i).count(_ == 'W') + s.slice(i + 1, n).count(_ == 'E')
    ans = math.min(ans, sum)
  }
  println(ans)
}
