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