solve :: Bool -> [Char] -> Int
solve _ [] = 0
solve True "W" = 0
solve True "E" = 1
solve False ('E':xs) = solve False xs
solve False ('W':xs) = min (solve True xs) (1 + solve False xs)
solve True ('W':xs) = solve True xs
solve True ('E':xs) = 1 + solve True xs

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