main = do
  n <- getLine
  s <- getLine
  putStrLn $ show $ (-1) $ minimum $ solve s 0 [0]
  
solve :: String -> Int -> [Int] -> [Int]
solve (x:xs) i m
  | x == 'E' = solve xs (i+1) ((last m +1):m)
  | x == 'W' = solve xs (i+1) ((last m):(map (+1) m))
solve [] i m = m
