import Foundation

let N = Int(readLine()!)!
let string = readLine()!
var chars: [Character] = []
var answers: [Int] = []

for char in string {
    chars.append(char)
}

func left(index: Int, count: Int) -> Int {
    let previous = index - 1
    var leftcount = count
    
    guard previous >= 0 else { return leftcount }
    
    if chars[previous] == "W" { leftcount += 1 }

    return left(index: previous, count: leftcount)
}

func right(index :Int, count: Int) -> Int {
    let next = index + 1
    var rightcount = count
    
    guard next < N else { return rightcount }
    
    if chars[next] == "E" { rightcount += 1 }
    
    return right(index: next, count: rightcount)
}

for leader in 0..<N {
    answers.append(left(index: leader, count: 0) + right(index: leader, count: 0))
}

print(answers.sorted(by: <).first!)
