fun main(args: Array<String>) {
    val N = nextInt()
    val S = next()
    val L = IntArray(N + 1)
    val R = IntArray(N + 1)
    for (n in 0 until N) {
        L[n + 1] = L[n] + (if (S[n] == 'E') 1 else 0)
    }
    for (n in (0 until N).reversed()) {
        R[n] = R[n + 1] + (if(S[N - n - 1] == 'W') 1 else 0)
    }
    var ans = Int.MAX_VALUE
    for (n in 0 until N) {
        ans = Math.min(ans, (L[N] - L[n + 1]) + (R[N - n] - R[N]))
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }
