import kotlin.math.abs
import kotlin.math.min

fun main() {
    val n = readInt()
    val colors = readLn()
    val white = colors.count { it == 'W' }
    val whiteSuffix = IntArray(n)
    for (i in n - 1 downTo 0) {
        if (colors[i] == 'W') whiteSuffix[i] = 1
        if (i < n - 1) whiteSuffix[i] += whiteSuffix[i + 1]
    }

    var best = Int.MAX_VALUE
    for (i in n downTo 0) {
        val d = n - i
        val change = abs(white - d)
        val swaps = if (i < n) d - whiteSuffix[i] else d
        best = min(best, change + swaps)
    }

    println(best)
}

// Input Reader
private fun readLn() = readLine()!!

private fun readInt() = readLn().toInt()
