import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import qualified Data.IntMap as I
import qualified Data.Map as M

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

solve :: Int -> String -> Int
solve n s = minimum (g s) + h s

h :: String -> Int
h s = length $ filter ('E'==) (tail s)

g :: String -> [Int]
g s = foldl f [0] (zip s (tail s))

f :: [Int] -> (Char,Char) -> [Int]
f [] _ = [0]
f all@(x:xs) (c,d) = x':all
    where x' = x + cc + dd
          cc = if c == 'W' then 1 else 0
          dd = if d == 'E' then -1 else 0