checkList s moji = fmap (\a -> if a == moji then 1 else 0) s

listW s = scanl (+) 0 (checkList s 'W')
listE s = scanr (+) 0 (checkList s 'E')

solve s = minimum $ zipWith (+) (listW s) (listE s)

main = do
    n <- getLine
    s <- getLine
    putStrLn $ show $ solve s