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

    var sum = Array(n) { i -> 0}
    var w = 0
    s.forEachIndexed {i, c ->
        sum[i] += w
        w += if (c == 'W') 1 else 0
    }
    var e = 0
    s.reversed().forEachIndexed {i, c ->
        sum[n - i - 1] += e
        e += if (c == 'E') 1 else 0
    }
    println(sum.min())
}