import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B

solve :: B.ByteString -> VU.Vector Int
solve bs = 
    VU.zipWith (+)
        (VU.scanl (\a x -> step 'W' a x) 0 (VU.fromList $ B.unpack bs))
        (VU.scanr (\x a -> step 'E' a x) 0 (VU.fromList $ B.unpack bs))
    where
        step :: Char -> Int -> Char -> Int
        step c a x
            | c == x = a + 1
            | otherwise = a

main = do
    n <- readLn :: IO Int
    s <- B.getLine
    print $ VU.minimum $ solve s