
fun main(args:Array<String>) {
    val itemCount = readLine()!!.toInt()
    val input = readLine()!!.trim()

    val toRight = (1..itemCount).map { 0 }.toMutableList()
    val toLeft = (1..itemCount).map { 0 }.toMutableList()

    for(i in input.indices) {
        var n = if(i>0) toRight[i-1] else 0
        if(input[i] == 'E') {
            n++
        }
        toRight[i] = n
    }

    for(i in input.indices.reversed()) {
        var n = if(i == input.lastIndex) 0 else toLeft[i+1]
        if(input[i] == 'W') {
            n++
        }
        toLeft[i] = n
    }

    var ans = 0
    for(i in input.indices) {
        var tmp = 1
        if(i > 0) {
            tmp += toRight[i-1]
        }
        if(i < input.lastIndex) {
            tmp += toLeft[i+1]
        }
        ans = Math.max(ans, tmp)
    }
    ans = itemCount - ans
    println(ans)
}


