import           GHC.Int
import qualified Data.ByteString.Lazy.Char8    as BC

main = do
    n  <- readLn :: IO Int64
    as <- BC.getContents
    print $ minimum [ g $ BC.splitAt k as | k <- [0 .. n - 1] ]
    
g t = BC.count 'W' (fst t) + BC.count 'E' (snd t)
