let N = Int(readLine()!)!
let S = readLine()!.characters.map{$0}
var a = (1..<N).reduce(0){$0+(S[$1]=="E" ?1:0)}
var ans = a
for i in 1..<N {
    if S[i] == "E" {
        a -= 1
    }
    if S[i-1] == "W" {
        a += 1
    }
    ans = min(a, ans)
    print(a)
}
print(ans)