import Data.List
import Debug.Trace

main = do
  n <- read <$> getLine :: IO Int
  ss <- getLine :: IO String
  print $ solve ss

solve :: String -> Int
solve ss =
  ans
  where
    cost = map (\s -> if s=='E' then 1 else (0-1)) ss
    cumsum = scanl1 (+) cost :: [Int]
    pos = case elemIndex (maximum  cumsum) cumsum of
      Just a -> a
    (r,l) = splitAt pos ss
    ans =
      --traceShow (r,l) $
      --traceShow (cumsum!!pos) $
      --if (cumsum!!pos)>=0 then
        case length (filter (=='W') r) of
        0 -> 0
        otherwise -> length (filter (=='W') r) - 1
        + length (filter (=='E') l)