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

main :: IO ()
main = do
  _n <- read <$> getLine :: IO [Int]
  s <- getLine :: IO String
  print $ solve s
