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

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
          cumulativeW = listArray (0, n) (scanl (+) 0 indicatorW)
          cumulativeE = listArray (0, n) (scanl (+) 0 indicatorE)
          partialSumW :: Int -> Int -> Int
          partialSumW start end = (cumulativeW ! end) - (cumulativeW ! start)
          partialSumE :: Int -> Int -> Int
          partialSumE start end = (cumulativeE ! end) - (cumulativeE ! start)
          numNotFaceLeader :: Int -> Int
          numNotFaceLeader leader = (partialSumW 0 leader) + (partialSumE leader n)

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