check a str = incheck $ splitAt a str
 where
  incheck (_,[])    =[]
  incheck (xs,y:ys) = length ( filter ('W'==) xs) + length (filter ('E'==) ys) : check (a+1) str


main = do
 _ <- getLine
 str <- getLine
 print $minimum$  check 0 str