
cumulative :: [Int] -> [Int]
--cumulative xs = f xs 0
--  where
--    f [] a = []
--    f (x:xs) a = (x + a):(f xs $ x + a)
cumulative xs = reverse $ f xs [0]
  where
    f [] ys = ys
    f (x:xs) (y:ys) = f xs $ (y + x):y:ys

main = do
  _ <- getLine
  s <- getLine
  let en = reverse $ cumulative $ reverse $ map (\c -> if c == 'E' then 1 else 0) s
  let wn = cumulative $ map (\c -> if c == 'W' then 1 else 0) s
  print $ subtract 1 $ minimum $ zipWith (+) en wn
