{-# LANGUAGE BangPatterns #-}

module Main where

import Control.Applicative
import Control.Monad
import Data.List

solve :: Int -> String -> Int
solve n xs = iter maxBound (0, 0) xs
  where
    en = length $ filter (== 'E') xs
    wn = n - en
    iter :: Int -> (Int, Int) -> String -> Int
    iter !c _        [] = c
    iter !c (!e, !w) ('E':xs) =
       iter (min c (w + (en - e - 1))) (e + 1, w) xs
    iter !c (!e, !w) ('W':xs) =
       iter (min c (w + (en - e)))     (e, w + 1) xs

main :: IO ()
main = do
    n <- readLn :: IO Int
    ss <- getLine
    print $ solve n ss