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

    val countEastForRight = mutableListOf<Int>()
    countEastForRight.add(0)
    for(i in (0 until n - 1).reversed()) {
        if(s[i + 1] == 'E') {
            countEastForRight.add(countEastForRight.last() + 1)
        } else {
            countEastForRight.add(countEastForRight.last())
        }
    }
    countEastForRight.reverse()
    val countWestForLeft = mutableListOf<Int>()
    countWestForLeft.add(0)
    for(i in (1 until n)) {
        if(s[i-1] == 'W') {
            countWestForLeft.add(countWestForLeft.last() + 1)
        } else {
            countWestForLeft.add(countWestForLeft.last())
        }
    }
    var ans = s.length
    for(i in (0 until n)) {
        ans = Math.min(ans, countEastForRight[i] + countWestForLeft[i])
    }
    println(ans)
}