main = do
  n <- readLn
  s <- getLine
  print $ solve n s

solve :: Int -> String -> Int
solve n s =
  minimum $ map (\(x, y) -> x + y) $ scanl go (0, length $ filter (=='E') s) s_
  where
    s_ = reverse . tail . reverse $ s
    go (l, r) a =
      if a == 'W' then
        (l+1, r)
      else
        (l, r-1)