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
    (l,r) = splitAt pos ss
    ans =
      --traceShow (l,r) $
      case length (filter (=='W') l) of
        0 -> 0 + length (filter (=='E') (tail r)) 
        otherwise -> length (filter (=='W') l)  + length (filter (=='E') (tail r)) -1 
      
