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