main = do
    (n:_) <- (fmap read . words) <$> getLine
    str <- getLine

    -- choose leader
    let numList = [(count 'W' $ take (b-1) str) + (count 'E' $ drop b str) | b<-[1..n]]
    print $ minimum numList


count :: Eq a => a -> [a] -> Int
count c = length . filter (c==)
