fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val S = readLine()!!


    val w = IntArray(N + 1) // [0, i) までのw数
    w[0] = 0
    val e = IntArray(N + 1) // [i, N) までのw数
    e[N] = 0
    for (i in 0 until N) {
        if (S[i] == 'W') {
            w[i + 1] = w[i] + 1
        } else {
            w[i+1] = w[i]
        }
    }
    for (i in N - 1 downTo 0) {
        if (S[i] == 'E') {
            e[i] = e[i + 1] + 1
        } else {
            e[i] = e[i + 1]
        }
    }


    var answer = Int.MAX_VALUE
    for (leader in 0 until N) {
        val num = w[(leader + 1) - 1] + e[leader + 1]
        answer = Math.min(answer, num)
    }
    println(answer)
}
