import java.util.*

private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

private inline fun <T> T.also(block: (T) -> Unit): T { block(this); return this }

private inline fun <T, R> Collection<T>.scanIndexed(initial: R, operation: (Int, R, T) -> R): List<R> {
    val result = ArrayList<R>(size)
    var prevResult = initial
    forEachIndexed { index, element ->
        val elementResult = operation(index, prevResult, element)
        result.add(elementResult)
        prevResult = elementResult
    }
    return result
}

private inline fun <T> Collection<T>.scanIndexed1(operation: (Int, T, T) -> T): List<T>
        = drop(1).scanIndexed(first(), operation)

private inline fun <T, R> Collection<T>.scan(initial: R, operation: (R, T) -> R): List<R>
        = scanIndexed(initial) {i, list, elem -> operation(list, elem) }

fun main(args: Array<String>) {
    val N = readInts()[0]
    val S = readStrings()[0]
    val initial = S.count { it == 'E' }
    var prevW = false
    val counts = S.toList().scan(initial) { count, direction ->
        when {
            prevW && direction == 'E' -> count
            prevW && direction == 'W' -> count + 1
            !prevW && direction== 'E' -> count - 1
            !prevW && direction== 'W' -> count
            else -> throw Exception()
        }.also {
            prevW = direction == 'W'
        }
    }
    println(counts.min()!!)
}