main :: IO ()
main = do
    n <- readLn
    s <- getLine
    let f leader = [() | i <- [0 .. n - 1], i /= leader, (if i < leader then not else id) $ [c == 'E' | c <- s] !! i]
    print . minimum $ map (length . f) [0 .. n - 1]
