import Control.Applicative ((<$>), (<*>))
import Data.List (foldl')

main :: IO ()
main = solve <$> readLn <*> getLine >>= print

solve :: Int -> String -> Int
solve n ss = g . foldl' f (n, 0, l) $ ss
  where l = length $ filter (== 'E') ss
        f (ct, wc, ec) ld | ld == 'W' = let ct' = wc + ec in (min ct ct', wc+1, ec)
                          | otherwise = let ct' = wc + ec - 1 in (min ct ct', wc, ec-1)
        g (x, _, _) = x
