(defn incFirstP [p a b]
  (if (p b)
    (inc a)
    a))

(defn eqW [x]
  (= \W x))

(defn eqE [x]
  (= \E x))

(defn incW [a b]
  ((partial incFirstP eqW) a b))

(defn incE [a b]
  ((partial incFirstP eqE) a b))

(defn sumE [xs]
  (reduce incE 0 xs))

(defn decE [a b]
  (if (eqE b)
    (dec a)
    a))

(defn attension [n xs]
  (->> (map +
            (reductions incW 0 xs)
            (reductions decE (sumE xs) xs))
       (apply min)))

 (println (attension (Long/parseLong (read-line)) (read-line)))
 