import Control.Applicative
import Data.List
import Control.Monad
import Data.Function
import Data.Array

getLineN :: Int -> IO [String]
getLineN n = replicateM n getLine

main = do
    _ <- getLine
    s <- getLine
    putStrLn.show.minimum $ map (answer s) [1..(length s-1)]

answer :: String -> Int -> Int
answer s k = count west 'W' + count east 'E' where
    west = take k s
    east = drop k s
    count ss c = length $ filter (==c) ss