fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()
    val s = sc.next()
    var left = 0
    var right = s.substring(1 until n).count { it == 'E' }
    val first = left + right
    println((1 until n).map {
        if (s[it - 1] == 'W') left++
        if (s[it] == 'E') right--
        left + right
    }.plus(first).min())
}
