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

make :: B.ByteString -> VU.Vector (Int, Int)
make bs = VU.scanl' step (0,0) (VU.fromList $ B.unpack bs)
    where
        step (a,b) c
            | c == 'W' = (a + 1, b)
            | otherwise = (a, b + 1)

solve :: VU.Vector (Int, Int) -> (Int, Int) -> B.ByteString -> Int -> Int
solve vec (a, b) bs i
    | VU.null vec = 10^9
    | otherwise = min res (solve (VU.tail vec) (a, b) bs (i + 1))
        where
            curr = B.index bs i
            (lw, le) = VU.head vec
            (rw, re) = (a-lw, b-le) 
            res = if curr == 'W' then lw - 1 + re else lw + re

main = do
    n <- readLn :: IO Int
    s <- B.getLine
    let m = make s
    print $ solve (VU.tail m) (VU.last m) s 0