import Control.Applicative
import Data.List
import Data.Array

partialSum :: (Num a) => [a] -> Int -> Int -> a
partialSum xs = \start -> \end -> (cumulative !end) - (cumulative !start)
    where cumulative = listArray (0, length xs) (scanl (+) 0 xs)

solve :: Int -> String -> Int
solve n s = minimum (map numNotFaceLeader [0..n-1])
    where indicatorW = fmap (\x -> if x == 'W' then 1 else 0) s
          indicatorE = fmap (\x -> if x == 'E' then 1 else 0) s
          partialSumW = partialSum indicatorW
          partialSumE = partialSum indicatorE
          numNotFaceLeader :: Int -> Int
          numNotFaceLeader leader = (partialSumW 0 leader) + (partialSumE (leader + 1) n)

main :: IO ()
main = do
    n <- readLn
    s <- getLine
    putStrLn $ show (solve n s)
