import Control.Monad
import Data.List

cnt (_:ss) = length $ filter (== 'E') ss

sel ln [s] = [ln]
sel ln (s1:s2:ss) =
    let ln' = if s1 == 'W' then ln+1 else ln
        ln'' = if s2 == 'E' then ln'-1 else ln'
    in ln : (sel ln'' (s2:ss))

main = do
    n <- readLn :: IO Int
    s <- getLine
    let ln = cnt s
    print $ minimum $ sel ln s
 