type Zipper a = ([a],[a])
                                                                                                                           
left :: Int -> Zipper a -> Zipper a
left 0 (xs,ys) = (xs,ys)
left _ ([],ys) = ([],ys)
left n (x:xs,ys) = left (n-1) (xs,x:ys)

right :: Int -> Zipper a -> Zipper a
right 0 (xs,ys) = (xs,ys)
right _ (xs,[]) = (xs,[])
right n (xs,y:ys) = right (n-1) (y:xs,ys)

now :: Zipper a -> Maybe a
now ([],_) = Nothing
now (x:xs,ys) = Just x

fromList :: Int -> [a] -> Zipper a
fromList n xs = right n ([],xs)

toList :: Zipper a -> [a]
toList (xs,ys) = snd $ left (length xs) (xs,ys)

count :: Zipper Char -> [(Int,Int)]
count (x:xs,[]) = (length (filter (=='W') xs),0):[]
count ([],y:ys) = count ([y],ys)
count (x:xs,y:ys) = ((head counts) `dplus` (l,r)):counts
  where counts = count (y:x:xs,ys)
        dplus (a,b) (c,d) = (a+c,b+d)
        l = if (x == 'W') then (-1) else 0
        r = if (y == 'E') then 1 else 0


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

  print $ foldr1 min $ map (\(x,y) -> x+y) (count $ fromList 0 xs)