{-# LANGUAGE BangPatterns #-}
main :: IO ()
main = do
  _ <- readLn :: IO Int
  xs <- getLine :: IO String    
  let ws = scanl (\ !a !x -> if x=='W' then a+1 else a) 0 xs :: [Int]
  let es = scanr (\ !x !a -> if x=='E' then a+1 else a) 0 xs :: [Int]
  print $ minimum $ zipWith (+) ws es
  

