fun main(args: Array<String>) {
    readLine()!!
    val s = readLine()!!
    val ecnt = s.count { it == 'E' }
    var e = 0
    var w = 0
    var ans = Int.MAX_VALUE
    for (c in s) {
        val x = w
        if (c == 'E') e++ else w++
        ans = Math.min(ans, x + ecnt - e)
    }
    println(ans)
}
