import Data.List (take)

countToWest :: String -> Int
countToWest s = length $ filter (== 'W') s

countToEast :: String -> Int
countToEast s = length $ filter (== 'E') s

solve :: Int -> String -> Int
solve n s = minimum [countToWest x1 + countToEast x2 | index <- [1..n], let (x1, x2) = (take (index - 1) s, drop index s)]

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