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

    val sumE = IntArray(n){0}
    val sumW = IntArray(n){0}

    sumE[0] = if (ss[0] == 'E') 1 else 0
    sumW[0] = if (ss[0] == 'W') 1 else 0

    for (i in 1 until n) {
        if (ss[i] == 'E') {
            sumE[i] = sumE[i-1] + 1
            sumW[i] = sumW[i-1]
        } else {
            sumE[i] = sumE[i-1]
            sumW[i] = sumW[i-1] + 1
        }
    }

    var min = sumE[n-1] - sumE[0]

    for (i in 1 until n) {
        min = Math.min(min, sumW[i-1] + sumE[n-1] - sumE[i])
    }

    println(min)
}