import Data.List

main :: IO ()
main = getLine >> getLine >>= print . solve 

-- |
-- >>> solve "WEEWW"
-- 1
-- >>> solve "WEWEWEEEWWWE"
-- 4
-- >>> solve "WWWWWEEE"
-- 3
solve :: String -> Int 
solve xs = minimum $ count 0 ec xs
    where
        ec = foldl' ff 0 xs
        ff acc 'E' = acc + 1
        ff acc _ = acc

        count a b ('W' : ys) = (a + b) : count (a + 1) b ys
        count a b (_ : ys) = (a + b - 1) : count a (b - 1) ys
        count _ _ _ = []