main = do
  n <- getLine
  s <- getLine
  putStrLn . show . solve $ s


solve :: String -> Int
solve s = solveHelper (0,0) s (calcEW s)

solveHelper (le, lw) [] (re,rw) = 0
solveHelper (le, lw) (x:[]) (re,rw) = lw
solveHelper (le, lw) (x:xs) (re,rw) = 
  if x == 'E' then 
    min (solveHelper (le+1,lw) xs (re-1,rw)) (lw + re - 1)
  else 
    min (solveHelper (le, lw+1) xs (re, rw-1)) (lw + re)

calcEW [] = (0,0)
calcEW (x:xs) = 
  let (e,w) = calcEW xs
  in if  x == 'E' then (e+1,w) else (e,w+1)