main :: IO ()
main = getLine >> solve <$> getLine >>= print

solve :: String -> Int
solve s = minimum $ zipWith (+) ws es
  where
    ws = init $ scanl (\n x -> if x == 'W' then n + 1 else n) 0 s
    es = tail $ scanr (\x n -> if x == 'E' then n + 1 else n) 0 s