fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val n = sc.nextInt()
        val s = sc.next()
        val f = Array(n) { 0 }
        for (i in 0 until n - 1) {
            f[i + 1] = f[i]
            if (s[i] == 'W') f[i + 1]++
        }

        val b = Array(n) { 0 }
        for (i in n - 1 downTo 1) {
            b[i - 1] = b[i]
            if (s[i] == 'E') b[i - 1]++
        }

        var ans = Int.MAX_VALUE
        for (i in 0 until n) {
            ans = Math.min(ans, f[i] + b[i])
        }
        println(ans)
    }
}


class MyScanner() {
    private var index = 0
    private var line = listOf<String>()

    fun next(): String {
        while (line.size <= index) {
            line = readLine()!!.split(' ')
            index = 0
        }
        return line[index++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]
}