import Control.Arrow
import Control.Monad
import Data.Bits
import qualified Data.ByteString.Char8 as BC
import Data.Char
import Data.List
import Data.Maybe

main :: IO ()
main = do
  _ <- getInt
  s <- getString
  let ws = init $ scanl (\a c -> if c == 'W' then a + 1 else a) 0 s
  let es = tail $ scanr (\c a -> if c == 'E' then a + 1 else a) 0 s
  print . minimum $ zipWith (+) ws es

getInt :: IO Int
getInt = readLn

getString :: IO String
getString = getLine
