aa0 :: String -> Int -> Int
aa0 xs n = (length $ filter (=='W') $ take (n-1) xs) + (length $ filter (=='E') $ drop n xs)

main :: IO ()
main = do
  n <- (read :: String -> Int) <$> getLine
  xs <- getLine

  print $ foldr min n $ map (aa0 xs) [1..n-1]  