import Data.List

main = do
    getLine
    s <- getLine
    print . minimum $ zipWith (\p q -> snd p + fst q) (scanl ew (0,0) s) (tail (scanr (flip ew) (0,0) s))
    
ew (e,w) h | h == 'E' = (e+1,w)
           | h == 'W' = (e,w+1)