count :: String -> Char -> Int -> [Int]
count [] _ _ = []
count (s:ss) d c = next : count ss d next
  where next = if s == d then c + 1 else c

solve :: [Int] -> [Int] -> [Int]
solve [] _ = []
solve (w:ws) (e:es) = w + e : solve ws es

main :: IO ()
main = do
  getLine
  s <- getLine
  let ws = (0:) . init $ count s 'W' 0
  let es = (++[0]) . tail . reverse $ count (reverse s) 'E' 0
  print . minimum $ solve ws es