import Control.Monad
import Text.Printf
import Control.Applicative

main :: IO()
main = do
  n <- getLine
  s <- getLine
  printf "%s" $ slv s

slv :: String -> String
slv s = show $ minimum $ zipWith (+) countListW (reverse (tail countListE)) 
  where countListW = scanl (+) 0 $ map (conv 'W') s
        countListE = scanl (+) 0 $ map (conv 'E') (reverse s)
        
conv :: Char -> Char -> Int
conv c d | c == d = 1
         | otherwise = 0 