import Data.List
import Control.Monad
import Prelude hiding (fst, snd)

data Orient = E | W deriving (Show, Eq)

orient :: Char -> Orient
orient c = case c of
	'E' -> E
	otherwise -> W

trisp :: Int -> [a] -> ([a], a, [a])
trisp 0 ls@(x:xs) = ([], (head ls), (tail ls))
trisp i ls@(x:xs) = ((take i ls), (ls !! i), (reverse (take i' rev)))
	where
		rev = reverse ls
		i' = (length ls) - i -1

fst (a, _, _) = a
snd (_, b, _) = b
thd (_, _, c) = c

countLeft :: Int -> [Orient] -> Int
countLeft acc [] = acc
countLeft acc (x:xs) = if x == W then countLeft (acc+1) xs else countLeft acc xs

countRight :: Int -> [Orient] -> Int
countRight acc [] = acc
countRight acc (x:xs) = if x == E then countRight (acc+1) xs else countRight acc xs

main = do
	line <- fmap (\x -> read x :: Int) getLine
	str' <- getLine
	let str = map orient str'
	anss <- forM [0..(line-1)] $ \i -> do
		let sp = trisp i str
		let ans = (countLeft 0 (fst sp)) + (countRight 0 (thd sp))
		return ans
	putStrLn $ show $ minimum anss