let rec iter a b f = if a >= b then () else (f a; iter (a+1) b f)
let () =
  Scanf.scanf "%d %s" @@ fun n s ->
  let w = Array.init n (fun i -> if s.[i] = 'W' then 1 else 0) in
  let e = Array.init n (fun i -> if s.[i] = 'E' then 1 else 0) in
  iter 1 n (fun i -> w.(i) <- w.(i) + w.(i-1));
  iter 1 n (fun i -> e.(n-1-i) <- e.(n-1-i) + e.(n-i));
  Array.init n (fun i ->
    (if i > 0 then w.(i-1) else 0) + (if i+1 < n then e.(i+1) else 0))
  |> Array.fold_left min n |> Printf.printf "%d\n"