import java.lang.Math.min

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    var m = n
    var current = s.count { it == 'E' }
    for(i in 0 until n){
        if(s[i] == 'E') current--
        if(i > 0 && s[i-1] == 'W') current++
        m = min(m, current)
    }
    print(m)
}