import Data.List (inits, tails)

cuts :: [a] -> [([a], [a])]
cuts xs = zip (inits $ init xs) (tails $ tail xs)

solve :: String -> Int
solve = minimum . map (\(w,e) -> length $ filter (== 'W') w ++ filter (== 'E') e) . init . cuts

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