fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val S = readLine()!!
    val T = IntArray(N).apply { this[0] = if (S[0] == 'W') 1 else 0 }
    val U = IntArray(N).apply { this[N - 1] = if (S[N - 1] == 'E') 1 else 0 }

    for (i in 1 until N) {
        T[i] = T[i - 1] + if (S[i] == 'W') 1 else 0
        U[N - 1 - i] = U[N - i] + if (S[N - 1 - i] == 'E') 1 else 0
    }

    val a = IntArray(N).apply { this[0] = U[1]; this[N - 1] = T[N - 2] }
    for (i in 1 until N - 1) {
        a[i] = T[i - 1] + U[i + 1]
    }
    println(a.min())
}