{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}

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

solve :: Int -> String -> Int
solve n s = minimum $ zipWith (+) (init ws) (tail es) where
  ws = scanl (\w c -> if c == 'W' then w + 1 else w) 0 s
  es = scanr (\c e -> if c == 'E' then e + 1 else e) 0 s
