
main = do
    _ <- getLine
    str <- getLine
    let cW = countFound 'W' str
    let cE = countFound 'E' $ reverse str

    let numList = zipWith (+) cW (reverse cE)
    print $ minimum numList


countFound :: Eq a => a -> [a] -> [Int]
countFound target = aux [0]
    where
        aux ac [] = ac
        aux (x:xs) (s:ss)
            | s==target = aux ((x+1):x:xs) ss
            | otherwise = aux (x:x:xs) ss