{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Data.List (mapAccumL)

main :: IO ()
main = do
  n <- readLn
  s <- getLine
  print $ solve n s

solve :: Int -> String -> Int
solve n s = minimum . snd $ mapAccumL f (0, length . filter (== 'E') $ tail s) s where
  f (a, b) 'E' = ((a, b - 1), a + b)
  f (a, b) 'W' = ((a + 1, b), a + b)
